Example usage for java.lang Integer getClass

List of usage examples for java.lang Integer getClass

Introduction

In this page you can find the example usage for java.lang Integer getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:de.thingweb.servient.ServientTestHttp.java

@Test
public void setAndReadPropertyDirectly() throws Exception {
    thing.setProperty("number", 42);
    Integer number = (Integer) server.getThing("SimpleThing").getProperty("number");
    assertThat("should be Integer", number.getClass(), equalTo(Integer.class));
    assertThat("value is 42", number, is(42));
}

From source file:com.processpuzzle.persistence.domain.InMemoryPersistenceProvider.java

@Override
public Integer add(UnitOfWork work, Class<? extends PersistentObject> entityClass, PersistentObject entity) {
    Integer id = createId();
    getEnityMap(entityClass).put(id, entity);
    try {//from w ww . ja  v a  2 s  .  c om
        entity.getClass().getMethod("setId", new Class[] { id.getClass() }).invoke(entity, new Object[] { id });
    } catch (Exception e) {
        e.printStackTrace();
    }
    return id;
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationPropertiesWithIntegerArray() {
    ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray();

    Integer integerValue = config.integerArray[0];

    assertEquals(Integer.class, integerValue.getClass());
    assertEquals(Integer.MAX_VALUE, integerValue.intValue());
    assertEquals(4, config.integerArray.length);
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationXMLWithIntegerArray() {
    ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray();

    Integer integerValue = config.integerArray[0];

    assertEquals(Integer.class, integerValue.getClass());
    assertEquals(Integer.MAX_VALUE, integerValue.intValue());
    assertEquals(4, config.integerArray.length);
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java

@Test
public void testConfigurationPropertiesWithIntegerList() {
    ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList();

    Integer integerValue = config.integerList.get(0);

    assertEquals(Integer.class, integerValue.getClass());
    assertEquals(Integer.MAX_VALUE, integerValue.intValue());
    assertEquals(4, config.integerList.size());
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java

@Test
public void testConfigurationXMLWithIntegerList() {
    ConfigurationXMLWithList config = prepareConfigurationXMLWithList();

    Integer integerValue = config.integerList.get(0);

    assertEquals(Integer.class, integerValue.getClass());
    assertEquals(Integer.MAX_VALUE, integerValue.intValue());
    assertEquals(4, config.integerList.size());
}

From source file:ch.cyberduck.core.threading.ThreadPoolFactory.java

/**
 * @param size    Maximum pool size/*from  w  w  w.j  a v a2 s. c  o  m*/
 * @param handler Uncaught thread exception handler
 */
protected ThreadPool create(final String prefix, final Integer size,
        final Thread.UncaughtExceptionHandler handler) {
    final String clazz = PreferencesFactory.get().getProperty("factory.threadpool.class");
    if (null == clazz) {
        throw new FactoryException(
                String.format("No implementation given for factory %s", this.getClass().getSimpleName()));
    }
    try {
        final Class<ThreadPool> name = (Class<ThreadPool>) Class.forName(clazz);
        final Constructor<ThreadPool> constructor = ConstructorUtils.getMatchingAccessibleConstructor(name,
                prefix.getClass(), size.getClass(), handler.getClass());
        if (null == constructor) {
            log.warn(String.format("No matching constructor for parameter %s", handler.getClass()));
            // Call default constructor for disabled implementations
            return name.newInstance();
        }
        return constructor.newInstance(prefix, size, handler);
    } catch (InstantiationException | InvocationTargetException | ClassNotFoundException
            | IllegalAccessException e) {
        throw new FactoryException(e.getMessage(), e);
    }
}

From source file:com.aurel.track.fieldType.runtime.base.WBSComparable.java

@Override
public int compareTo(Object o) {
    WBSComparable wbsComparable = (WBSComparable) o;
    List<Integer> paramWbsOnLevelsList = wbsComparable.getWbsOnLevelsList();
    if ((wbsOnLevelsList == null || wbsOnLevelsList.isEmpty())
            && (paramWbsOnLevelsList == null || paramWbsOnLevelsList.isEmpty())) {
        return 0;
    }/*from w  w w.j  a v a 2 s. c  om*/
    if (wbsOnLevelsList == null || wbsOnLevelsList.isEmpty()) {
        return -1;
    }
    if (paramWbsOnLevelsList == null || paramWbsOnLevelsList.isEmpty()) {
        return 1;
    }
    int length = wbsOnLevelsList.size();
    int paramLength = paramWbsOnLevelsList.size();
    int minLength = length;
    if (minLength > paramLength) {
        minLength = paramLength;
    }
    for (int i = 0; i < minLength; i++) {
        Integer wbsOnLevel = wbsOnLevelsList.get(i);
        Integer paramWbsOnLevel = paramWbsOnLevelsList.get(i);
        if (wbsOnLevel == null && paramWbsOnLevel == null) {
            return 0;
        }
        if (wbsOnLevel == null) {
            return -1;
        }
        if (paramWbsOnLevel == null) {
            return 1;
        }
        try {
            int compareResult = wbsOnLevel.compareTo(paramWbsOnLevel);
            if (compareResult != 0) {
                //return only if the part if different
                return compareResult;
            }
        } catch (Exception e) {
            LOGGER.warn("Sorting the values " + wbsOnLevel + " of class " + wbsOnLevel.getClass().getName()
                    + " and " + paramWbsOnLevel + " of class " + paramWbsOnLevel.getClass().getName()
                    + " failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
    //ancestor-descendant relation: the longer the path the later in wbs
    return Integer.valueOf(length).compareTo(Integer.valueOf(paramLength));
}

From source file:org.apache.fop.area.Area.java

/**
 * Get a trait from this area as an integer.
 *
 * @param traitCode the trait key/*from w  w w  . ja  v a 2  s  .co m*/
 * @return the trait value
 */
public int getTraitAsInteger(Integer traitCode) {
    final Object obj = getTrait(traitCode);
    if (obj instanceof Integer) {
        return (Integer) obj;
    } else {
        throw new IllegalArgumentException(
                "Trait " + traitCode.getClass().getName() + " could not be converted to an integer");
    }
}