Class EntityIdentifierUtil

java.lang.Object
org.broadleafcommerce.core.util.EntityIdentifierUtil

public class EntityIdentifierUtil extends Object
Utility class that will search for the entity identifier property and/or property value
Author:
dcolgrove
  • Field Details

    • LOG

      protected static final org.apache.commons.logging.Log LOG
  • Constructor Details

    • EntityIdentifierUtil

      public EntityIdentifierUtil()
  • Method Details

    • getIdentifierFieldName

      public String getIdentifierFieldName(Object entity)
      Determine the field name with the @id annotation (jakarta.persistence.Id)
      Parameters:
      entity - Object reference of the entity/bean where the property is to be searched
      Returns:
      String representing the field name or null if the entity does not have an @Id annotation
    • getIdentifierFieldName

      public String getIdentifierFieldName(Class<?> clazz)
      Determine the field name with the @id annotation (jakarta.persistence.Id)
      Parameters:
      clazz - Class reference of the entity/bean where the property is to be searched
      Returns:
      String representing the field name or null if the entity does not have an @Id annotation
    • getIdentifierFieldValue

      public Serializable getIdentifierFieldValue(Object entity)
      Given the entity, finds the identifier property and returns the associated value
      Parameters:
      entity - Object reference of the entity/bean where the property is to be searched
      Returns:
      a Serializable instance of the value
    • getIdentifyFieldValue

      public Serializable getIdentifyFieldValue(Object entity, String primaryKeyFieldName)
      Given the entity and specific field name, returns the value of that field.
      Parameters:
      entity - Object reference of the entity/bean where the property is to be searched
      primaryKeyFieldName - the name of the field where the value will be taken
      Returns:
      a Serializable instance of the value
    • findIdentifierField

      protected Field findIdentifierField(Class<?> clazz)
      Determine the Reflection Field with the @id annotation (jakarta.persistence.Id) This assumes the @Id annotation will be on the property
      Parameters:
      clazz - Object reference of the entity/bean where the property is to be searched
      Returns:
      String representing the field name or null if the entity does not have an @Id annotation