List of usage examples for java.lang Class cast
@SuppressWarnings("unchecked") @HotSpotIntrinsicCandidate public T cast(Object obj)
From source file:org.ext4spring.parameter.converter.simple.StringConverter.java
@Override public <T> T toTypedValue(String stringValue, Class<T> type) { return type.cast(stringValue); }
From source file:org.ext4spring.parameter.converter.simple.ByteConverter.java
@Override public <T> T toTypedValue(String stringValue, Class<T> type) { return (stringValue != null) ? type.cast(Byte.parseByte(stringValue)) : null; }
From source file:org.ext4spring.parameter.converter.simple.CharacterConverter.java
@Override public <T> T toTypedValue(String stringValue, Class<T> type) { return (stringValue != null) ? type.cast(Character.valueOf(stringValue.charAt(0))) : null; }
From source file:org.ext4spring.parameter.converter.simple.DoubleConverter.java
@Override public <T> T toTypedValue(String stringValue, Class<T> type) { return (stringValue != null) ? type.cast(Double.parseDouble(stringValue)) : null; }
From source file:fr.inria.atlanmod.neoemf.core.PersistentEObjectAdapter.java
/** * Returns the given {@code object} adapted in a specific {@code type}. * * @param adaptableObject the object to adapt * @param adapterType the class in which the object must be adapted * * @return an adapted object in the given {@code type}, or {@code null} if the {@code object} cannot be assigned as * a {@code type}//from w ww . ja v a2 s . c o m * * @throws NullPointerException if the {@code type} is {@code null} */ public static <T extends PersistentEObject> T getAdapter(Object adaptableObject, Class<T> adapterType) { if (isNull(adaptableObject)) { return null; } checkNotNull(adapterType); Object adapter = null; if (adapterType.isInstance(adaptableObject)) { adapter = adaptableObject; } else if (adaptableObject instanceof InternalEObject) { adapter = ADAPTED_OBJECTS_CACHE.getIfPresent(adaptableObject); if (isNull(adapter) || !adapterType.isAssignableFrom(adapter.getClass())) { adapter = createAdapter(adaptableObject, adapterType); ADAPTED_OBJECTS_CACHE.put((InternalEObject) adaptableObject, (PersistentEObject) adapter); } } if (isNull(adapter)) { NeoLogger.warn("Unable to create a {0} adapter for this object of type {1}", adapterType.getSimpleName(), adaptableObject.getClass().getSimpleName()); } return adapterType.cast(adapter); }
From source file:org.ext4spring.parameter.converter.simple.FloatConverter.java
@Override public <T> T toTypedValue(String stringValue, Class<T> type) { return (stringValue != null) ? type.cast(Float.parseFloat(stringValue)) : null; }
From source file:org.ext4spring.parameter.converter.simple.IntegerConverter.java
@Override public <T> T toTypedValue(String stringValue, Class<T> type) { return (stringValue != null) ? type.cast(Integer.parseInt(stringValue)) : null; }
From source file:org.ext4spring.parameter.converter.simple.LongConverter.java
@Override public <T> T toTypedValue(String stringValue, Class<T> type) { return (stringValue != null) ? type.cast(Long.parseLong(stringValue)) : null; }
From source file:org.ext4spring.parameter.converter.simple.ShortConverter.java
@Override public <T> T toTypedValue(String stringValue, Class<T> type) { return (stringValue != null) ? type.cast(Short.parseShort(stringValue)) : null; }
From source file:org.sinekartapdfa.share.webscript.BaseWS.java
protected <T> T getParameter(WebScriptRequest req, String parameter, Class<T> tClass) { return tClass.cast(JavaWebscriptTools.getRequestParameter(req, parameter)); }