Record Class Component.Identifier<C>

java.lang.Object
java.lang.Record
org.axonframework.common.configuration.Component.Identifier<C>
Type Parameters:
C - The type of the component this object identifies, typically an interface.
Record Components:
type - The type reference of the component this object identifies.
name - The name of the component this object identifies, potentially null when unimportant. Will throw an IllegalArgumentException for an empty name.
Enclosing interface:
Component<C>

public static record Component.Identifier<C>(@Nonnull TypeReference<C> type, @Nullable String name) extends Record
A tuple representing a Component's uniqueness, consisting out of a type and name.
  • Constructor Details

    • Identifier

      public Identifier(@Nonnull Class<C> clazz, @Nullable String name)
      A tuple representing a Component's uniqueness, consisting out of a clazz and name.
      Parameters:
      clazz - The clazz of the component this object identifies, typically an interface.
      name - The name of the component this object identifies, potentially null when unimportant. Will throw an IllegalArgumentException for an empty name.
    • Identifier

      public Identifier(@Nonnull Type type, @Nullable String name)
      A tuple representing a Component's uniqueness, consisting out of a type and name.
      Parameters:
      type - The type of the component this object identifies, typically an interface.
      name - The name of the component this object identifies, potentially null when unimportant. Will throw an IllegalArgumentException for an empty name.
    • Identifier

      public Identifier(@Nonnull TypeReference<C> type, @Nullable String name)
      Compact constructor asserting whether the type and name are non-null and not empty.
      Parameters:
      type - The type of the component.
      name - The name of the component.
  • Method Details

    • matches

      public boolean matches(@Nonnull Component.Identifier<?> other)
      Validate whether the given other Identifier matches with this Identifier, by matching the names and checking if the type() is Class.isAssignableFrom(Class) to give other type.
      Parameters:
      other - The other identifier to compare with this identifier.
      Returns:
      true if the type() is assignable from the other type and the name() is identical, false otherwise.
    • matchesType

      public boolean matchesType(@Nonnull Component.Identifier<?> other)
      Validate whether the given other Identifier type matches with this Identifier type, by checking if the type() is Class.isAssignableFrom(Class) to give other type.
      Parameters:
      other - The other identifier to compare with this identifier.
      Returns:
      true if the type() is assignable from the other type, false otherwise.
    • typeAsClass

      public Class<C> typeAsClass()
      Returns the type() as a Class.

      This means any generics present on the type are lost. When those are needed, be sure to use type() instead.

      Returns:
      The type() as a Class.
    • areTypeAndNameEqual

      public boolean areTypeAndNameEqual()
      Checks whether the Class.getName() of this Identifier's given type is equal to the given name.
      Returns:
      true whenever the Class.getName() of this Identifier's given type is equal to the given name, false otherwise.
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • type

      @Nonnull public TypeReference<C> type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • name

      @Nullable public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component