public LookUpStrategy determineLookUpStrategy(Object object) {
        Class<?> objectClass = object.getClass();
        return decisionCache.computeIfAbsent(objectClass, key -> {
            if (object.getClass().isEnum()) {
                return new ImmutableLookUpStrategy();
            }
            switch (lookUpStrategyType) {
                case PLANNING_ID_OR_NONE:
                    MemberAccessor memberAccessor1 = ConfigUtils.findPlanningIdMemberAccessor(objectClass);
                    if (memberAccessor1 == null) {
                        return new NoneLookUpStrategy();
                    }
                    return new PlanningIdLookUpStrategy(memberAccessor1);
                case PLANNING_ID_OR_FAIL_FAST:
                    MemberAccessor memberAccessor2 = ConfigUtils.findPlanningIdMemberAccessor(objectClass);
                    if (memberAccessor2 == null) {
                        throw new IllegalArgumentException("The class (" + objectClass
                                + ") does not have a " + PlanningId.class.getSimpleName() + " annotation,"
                                + " but the lookUpStrategyType (" + lookUpStrategyType + ") requires it.\n"
                                + "Maybe add the " + PlanningId.class.getSimpleName() + " annotation"
                                + " or change the " + PlanningSolution.class.getSimpleName() + " annotation's "
                                + LookUpStrategyType.class.getSimpleName() + ".");
                    }
                    return new PlanningIdLookUpStrategy(memberAccessor2);
                case EQUALITY:
                    Method equalsMethod;
                    Method hashCodeMethod;
                    try {
                        equalsMethod = object.getClass().getMethod("equals", Object.class);
                        hashCodeMethod = object.getClass().getMethod("hashCode");
                    } catch (NoSuchMethodException e) {
                        throw new IllegalStateException(
                                "Impossible state because equals() and hashCode() always exist.", e);
                    }
                    if (equalsMethod.getDeclaringClass().equals(Object.class)) {
                        throw new IllegalArgumentException("The class (" + object.getClass().getSimpleName()
                                + ") doesn't override the equals() method, neither does any superclass.");
                    }
                    if (hashCodeMethod.getDeclaringClass().equals(Object.class)) {
                        throw new IllegalArgumentException("The class (" + object.getClass().getSimpleName()
                                + ") overrides equals() but neither it nor any superclass"
                                + " overrides the hashCode() method.");
                    }
                    return new EqualsLookUpStrategy();
                case NONE:
                    return new NoneLookUpStrategy();
                default:
                    throw new IllegalStateException("The lookUpStrategyType (" + lookUpStrategyType
                            + ") is not implemented.");
            }
        });
    }
public LookUpStrategy determineLookUpStrategy(Object object) {
        Class<?> objectClass = object.getClass();
        return decisionCache.computeIfAbsent(objectClass, key -> {
            if (object.getClass().isEnum()) {
                return new ImmutableLookUpStrategy();
            }
            switch (lookUpStrategyType) {
                case PLANNING_ID_OR_NONE:
                    MemberAccessor memberAccessor1 = ConfigUtils.findPlanningIdMemberAccessor(objectClass);
                    if (memberAccessor1 == null) {
                        return new NoneLookUpStrategy();
                    }
                    return new PlanningIdLookUpStrategy(memberAccessor1);
                case PLANNING_ID_OR_FAIL_FAST:
                    MemberAccessor memberAccessor2 = ConfigUtils.findPlanningIdMemberAccessor(objectClass);
                    if (memberAccessor2 == null) {
                        throw new IllegalArgumentException("The class (" + objectClass
                                + ") does not have a " + PlanningId.class.getSimpleName() + " annotation,"
                                + " but the lookUpStrategyType (" + lookUpStrategyType + ") requires it.\n"
                                + "Maybe add the " + PlanningId.class.getSimpleName() + " annotation"
                                + " or change the " + PlanningSolution.class.getSimpleName() + " annotation's "
                                + LookUpStrategyType.class.getSimpleName() + ".");
                    }
                    return new PlanningIdLookUpStrategy(memberAccessor2);
                case EQUALITY:
                    Method equalsMethod;
                    Method hashCodeMethod;
                    try {
                        equalsMethod = object.getClass().getMethod("equals", Object.class);
                        hashCodeMethod = object.getClass().getMethod("hashCode");
                    } catch (NoSuchMethodException e) {
                        throw new IllegalStateException(
                                "Impossible state because equals() and hashCode() always exist.", e);
                    }
                    if (equalsMethod.getDeclaringClass().equals(Object.class)) {
                        throw new IllegalArgumentException("The class (" + object.getClass().getSimpleName()
                                + ") doesn't override the equals() method, neither does any superclass.");
                    }
                    if (hashCodeMethod.getDeclaringClass().equals(Object.class)) {
                        throw new IllegalArgumentException("The class (" + object.getClass().getSimpleName()
                                + ") overrides equals() but neither it nor any superclass"
                                + " overrides the hashCode() method.");
                    }
                    return new EqualsLookUpStrategy();
                case NONE:
                    return new NoneLookUpStrategy();
                default:
                    throw new IllegalStateException("The lookUpStrategyType (" + lookUpStrategyType
                            + ") is not implemented.");
            }
        });
    }
public LookUpStrategy determineLookUpStrategy ( Object object ) { Class < ? > objectClass = object . getClass ( ) ; return decisionCache . computeIfAbsent ( objectClass , key -> { if ( object . getClass ( ) . isEnum ( ) ) { return new ImmutableLookUpStrategy ( ) ; } switch ( lookUpStrategyType ) { case PLANNING_ID_OR_NONE : MemberAccessor memberAccessor1 = ConfigUtils . findPlanningIdMemberAccessor ( objectClass ) ; if ( memberAccessor1 == null ) { return new NoneLookUpStrategy ( ) ; } return new PlanningIdLookUpStrategy ( memberAccessor1 ) ; case PLANNING_ID_OR_FAIL_FAST : MemberAccessor memberAccessor2 = ConfigUtils . findPlanningIdMemberAccessor ( objectClass ) ; if ( memberAccessor2 == null ) { throw new IllegalArgumentException ( "The class (" + objectClass + ") does not have a " + PlanningId . class . getSimpleName ( ) + " annotation," + " but the lookUpStrategyType (" + lookUpStrategyType + ") requires it.\n" + "Maybe add the " + PlanningId . class . getSimpleName ( ) + " annotation" + " or change the " + PlanningSolution . class . getSimpleName ( ) + " annotation's " + LookUpStrategyType . class . getSimpleName ( ) + "." ) ; } return new PlanningIdLookUpStrategy ( memberAccessor2 ) ; case EQUALITY : Method equalsMethod ; Method hashCodeMethod ; try { equalsMethod = object . getClass ( ) . getMethod ( "equals" , Object . class ) ; hashCodeMethod = object . getClass ( ) . getMethod ( "hashCode" ) ; } catch ( NoSuchMethodException e ) { throw new IllegalStateException ( "Impossible state because equals() and hashCode() always exist." , e ) ; } if ( equalsMethod . getDeclaringClass ( ) . equals ( Object . class ) ) { throw new IllegalArgumentException ( "The class (" + object . getClass ( ) . getSimpleName ( ) + ") doesn't override the equals() method, neither does any superclass." ) ; } if ( hashCodeMethod . getDeclaringClass ( ) . equals ( Object . class ) ) { throw new IllegalArgumentException ( "The class (" + object . getClass ( ) . getSimpleName ( ) + ") overrides equals() but neither it nor any superclass" + " overrides the hashCode() method." ) ; } return new EqualsLookUpStrategy ( ) ; case NONE : return new NoneLookUpStrategy ( ) ; default : throw new IllegalStateException ( "The lookUpStrategyType (" + lookUpStrategyType + ") is not implemented." ) ; } } ) ; }
This method is thread-safe.
@param object never null
@return never null
This method is thread - safe .