Example usage for java.lang Class equals

List of usage examples for java.lang Class equals

Introduction

In this page you can find the example usage for java.lang Class equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:cz.zcu.kiv.eegdatabase.logic.controller.root.ForgottenPasswordValidator.java

public boolean supports(Class clazz) {
    return clazz.equals(ForgottenPasswordCommand.class);
}

From source file:org.openmrs.logic.rule.definition.RuleDefinitionValidator.java

@SuppressWarnings("unchecked")
public boolean supports(Class c) {
    return c.equals(RuleDefinition.class);
}

From source file:org.openmrs.module.appointmentscheduling.validator.AppointmentTypeValidator.java

/**
 * Determines if the command object being submitted is a valid type
 * /* w w  w .j a va  2 s  .co  m*/
 * @see org.springframework.validation.Validator#supports(java.lang.Class)
 */
@SuppressWarnings("unchecked")
public boolean supports(Class c) {
    return c.equals(AppointmentType.class);
}

From source file:gr.abiss.calipso.util.ItemUtils.java

private static void initItemField(CalipsoService calipsoService, Item item, Asset asset, Field field,
        AssetTypeCustomAttribute assetTypeAttr, String value) {
    String itemFieldName = field.getName().getText();
    try {/*from   w w w . j a v  a  2s. c o m*/
        //logger.debug("initItemField, field name: "+itemFieldName);
        String firstLetter = itemFieldName.substring(0, 1);
        String remainingPart = itemFieldName.substring(1, itemFieldName.length());
        Method itemFieldGetter = Item.class.getMethod("get" + firstLetter.toUpperCase() + remainingPart);
        Class itemFieldType = itemFieldGetter.getReturnType();
        Method itemFieldSetter = Item.class.getMethod("set" + firstLetter.toUpperCase() + remainingPart,
                itemFieldType);

        // Integer/DropDown
        if (itemFieldType.equals(
                Integer.class)/*field.getFieldType().equals(Field.FIELD_TYPE_AUTOSUGGEST)
                              || field.getFieldType().equals(Field.FIELD_TYPE_DROPDOWN)
                              || field.getFieldType().equals(Field.FIELD_TYPE_DROPDOWN_HIERARCHICAL)*/) {
            if (value == null) {
                itemFieldSetter.invoke(item, (Integer) null);
            } else {
                boolean found = false;
                //logger.debug("Item field '"+field.getName().getText()+"' is of type 'options', iterating Asset attribute lookup values (options) for a deeper match");
                CustomAttributeLookupValue assetLookupValue = calipsoService
                        .loadCustomAttributeLookupValue(NumberUtils.createLong(value).longValue());

                //logger.info("assetLookupValue: '"+assetLookupValue);
                //logger.debug("Item field '"+field.getName().getText()+"' is of type 'options', iterating Asset attribute lookup values (options) for a deeper match on name: "+assetLookupValue.getName()+", showOrder: "+assetLookupValue.getShowOrder());
                // we need to find a matching showOrder in this one
                List<CustomAttributeLookupValue> itemLookupValues = calipsoService
                        .findLookupValues(item.getSpace(), field.getName().getText());
                if (assetLookupValue != null && CollectionUtils.isNotEmpty(itemLookupValues)) {
                    for (CustomAttributeLookupValue lookupValue : itemLookupValues) {
                        //logger.debug("Checking lookup value with value:'"+lookupValue);
                        if (lookupValue.getShowOrder() == assetLookupValue.getShowOrder()) {
                            itemFieldSetter.invoke(item, NumberUtils.createInteger(lookupValue.getId() + ""));
                            //logger.info("Found a match, result ID: "+itemFieldGetter.invoke(item));
                            found = true;
                            break;
                        }
                    }
                } else {
                    logger.warn("No lookup values found for attribute " + assetTypeAttr.getName());
                }
                // this should work for simple numbers
                if (!found) {
                    // logger.debug("No option matched, adding a simple number instead");
                    itemFieldSetter.invoke(item, new Integer(value));
                }
            }
        }
        // Long
        else if (itemFieldType.equals(Long.class)) {
            if (value == null) {
                itemFieldSetter.invoke(item, (Long) null);
            } else {
                itemFieldSetter.invoke(item, new Long(value));
            }
        }
        // Decimal
        else if (itemFieldType.equals(Double.class)) {
            if (value == null) {
                itemFieldSetter.invoke(item, (Double) null);
            } else {
                itemFieldSetter.invoke(item, new Double(value));
            }
        }
        // String
        else if (itemFieldType.equals(String.class)) {
            itemFieldSetter.invoke(item, value);
        }
        // Date
        else if (itemFieldType.equals(Date.class)) {
            if (value == null) {
                itemFieldSetter.invoke(item, (Date) null);
            } else {
                itemFieldSetter.invoke(item, DateUtils.convert(value));
            }
        }
        // Organization
        else if (itemFieldType.equals(Organization.class)) {
            if (value == null) {
                itemFieldSetter.invoke(item, (Organization) null);
            } else {
                itemFieldSetter.invoke(item, calipsoService.loadOrganization(new Long(value)));
            }
        }
        // User
        else if (itemFieldType.equals(User.class)) {
            if (value == null) {
                itemFieldSetter.invoke(item, (User) null);
            } else {
                itemFieldSetter.invoke(item, calipsoService.loadUser(new Long(value)));
            }
        }
        // Country
        else if (itemFieldType.equals(Country.class)) {
            if (value == null) {
                itemFieldSetter.invoke(item, (Country) null);
            } else {
                itemFieldSetter.invoke(item, calipsoService.loadCountry(value));
            }
        }
        // Asset
        else if (itemFieldType.equals(Asset.class) && NumberUtils.isDigits(value)) {
            if (value == null) {
                itemFieldSetter.invoke(item, (Asset) null);
            } else {
                // item.addAsset(calipsoService.loadAsset(new Long(value)));
            }
        } else {
            logger.warn("Could not convert asset attribute '" + assetTypeAttr.getName() + "' value (" + value
                    + ") to item field: " + itemFieldName);
        }
        //logger.info("Returning with Item "+assetTypeAttr.getName()+": "+itemFieldGetter.invoke(item));
    } catch (Exception e) {
        throw new RuntimeException("Could not convert asset attribute '" + assetTypeAttr.getName() + "' value ("
                + value + ") to item field: " + itemFieldName, e);
    }
}

From source file:od.lti.LTIAuthenticationProvider.java

@Override
public boolean supports(Class<?> authentication) {
    return authentication.equals(LTIAuthenticationToken.class);
}

From source file:org.openmrs.module.appointmentscheduling.validator.TimeSlotValidator.java

/**
 * Determines if the command object being submitted is a valid type
 * //w w  w  . j a  v  a2s  .  c  o  m
 * @see org.springframework.validation.Validator#supports(java.lang.Class)
 */
@SuppressWarnings("unchecked")
public boolean supports(Class c) {
    return c.equals(TimeSlot.class);
}

From source file:org.motechproject.server.omod.web.validator.WebCommunityValidator.java

public boolean supports(Class aClass) {
    return aClass.equals(WebCommunity.class);
}

From source file:sample.contact.AddPermissionValidator.java

@SuppressWarnings("unchecked")
public boolean supports(Class clazz) {
    return clazz.equals(AddPermission.class);
}

From source file:org.sloth.validation.ReportValidator.java

@Override
public boolean supports(Class<?> clazz) {
    return clazz.equals(Report.class);
}

From source file:com.hazelcast.simulator.probes.xml.HistogramConverter.java

@Override
public boolean canConvert(Class clazz) {
    return clazz.equals(Histogram.class);
}