本文整理汇总了Java中com.helger.commons.lang.GenericReflection.uncheckedCast方法的典型用法代码示例。如果您正苦于以下问题:Java GenericReflection.uncheckedCast方法的具体用法?Java GenericReflection.uncheckedCast怎么用?Java GenericReflection.uncheckedCast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.helger.commons.lang.GenericReflection
的用法示例。
在下文中一共展示了GenericReflection.uncheckedCast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: take
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
/**
* Take an element from the ring buffer.
*
* @return <code>null</code> if no more element is available or if the current
* element is <code>null</code>.
*/
@Nullable
public ELEMENTTYPE take ()
{
final int nAvailable = m_nAvailable;
if (nAvailable == 0)
return null;
int nIndex = m_nWritePos - nAvailable;
if (nIndex < 0)
nIndex += m_nCapacity;
final Object ret = m_aElements[nIndex];
m_nAvailable--;
return GenericReflection.uncheckedCast (ret);
}
示例2: take
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
/**
* Take an element from the ring buffer.
*
* @return <code>null</code> if no more element is available or if the current
* element is <code>null</code>.
*/
@Nullable
public ELEMENTTYPE take ()
{
final int nAvailable = m_nAvailable;
if (nAvailable == 0)
return null;
int nIndex = m_nWritePos - 1;
if (nIndex < 0)
nIndex += m_nCapacity;
final Object ret = m_aElements[nIndex];
m_nWritePos = nIndex;
m_nAvailable--;
return GenericReflection.uncheckedCast (ret);
}
示例3: toArray
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
@Nonnull
public <T> T [] toArray (@Nullable final T [] a)
{
MapEntry <K, V> [] result = null;
if (a != null && a instanceof MapEntry <?, ?> [] && a.length >= size ())
result = GenericReflection.uncheckedCast (a);
else
result = GenericReflection.uncheckedCast (new MapEntry <?, ?> [size ()]);
final Object [] aSrcArray = m_aSrcEntrySet.toArray ();
for (int i = 0; i < aSrcArray.length; i++)
{
final Map.Entry <K, SoftValue <K, V>> e = GenericReflection.uncheckedCast (aSrcArray[i]);
result[i] = new MapEntry<> (e.getKey (), e.getValue ().get ());
}
return GenericReflection.uncheckedCast (result);
}
示例4: _getRelationFromLastMatch
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
@Nullable
private static <N extends IMutableBaseGraphNode <N, R>, R extends IMutableBaseGraphRelation <N, R>> R _getRelationFromLastMatch (@Nonnull final WorkElement <N> aLastMatch,
@Nonnull final N aNode)
{
if (aNode.isDirected ())
{
// Directed
// Cast to Object required for JDK command line compiler
final Object aDirectedFromNode = aLastMatch.getToNode ();
final Object aDirectedToNode = aNode;
final IMutableDirectedGraphRelation r = ((IMutableDirectedGraphNode) aDirectedFromNode).getOutgoingRelationTo ((IMutableDirectedGraphNode) aDirectedToNode);
return GenericReflection.uncheckedCast (r);
}
// Undirected
return aLastMatch.getToNode ().getRelation (aNode);
}
示例5: evaluate
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
public static <T> T evaluate (@Nonnull final XPathExpression aXPath,
@Nonnull final Node aItem,
@Nonnull final QName aReturnType,
@Nullable final String sBaseURI) throws XPathExpressionException
{
Object aRealItem = aItem;
if (sBaseURI != null && "net.sf.saxon.xpath.XPathExpressionImpl".equals (aXPath.getClass ().getName ()))
{
// Saxon specific handling
// This is trick needed for #47 - "base-uri()"
final XPathExpressionImpl aImpl = (XPathExpressionImpl) aXPath;
aRealItem = new DocumentWrapper (XMLHelper.getOwnerDocument (aItem),
sBaseURI,
aImpl.getConfiguration ()).wrap (aItem);
}
return GenericReflection.uncheckedCast (aXPath.evaluate (aRealItem, aReturnType));
}
示例6: writeConvertedObject
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
public static <T> void writeConvertedObject (@Nullable final T aObject,
@Nonnull final ObjectOutputStream aOOS) throws TypeConverterException,
IOException
{
ValueEnforcer.notNull (aOOS, "ObjectOutputStream");
// Write boolean flag indicating null or not
aOOS.writeBoolean (aObject == null);
if (aObject != null)
{
// Lookup converter
final Class <T> aSrcClass = GenericReflection.uncheckedCast (aObject.getClass ());
final ISerializationConverter <T> aConverter = SerializationConverterRegistry.getInstance ()
.getConverter (aSrcClass);
if (aConverter == null)
throw new TypeConverterException (aSrcClass, EReason.NO_CONVERTER_FOUND_SINGLE);
// Perform conversion
aConverter.writeConvertedObject (aObject, aOOS);
}
}
示例7: getDeserializedObject
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
/**
* Convert the passed byte array to an object using deserialization.
*
* @param aData
* The source serialized byte array. Must contain a single object only.
* May not be <code>null</code>.
* @return The deserialized object. Never <code>null</code>.
* @throws IllegalStateException
* If deserialization failed
* @param <T>
* The type of the deserialized object
*/
@Nonnull
public static <T> T getDeserializedObject (@Nonnull final byte [] aData)
{
ValueEnforcer.notNull (aData, "Data");
// Read new object from byte array
try (final ObjectInputStream aOIS = new ObjectInputStream (new NonBlockingByteArrayInputStream (aData)))
{
return GenericReflection.uncheckedCast (aOIS.readObject ());
}
catch (final Exception ex)
{
throw new IllegalStateException ("Failed to read serializable object", ex);
}
}
示例8: _createValueArray
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
@Nonnull
@ReturnsMutableCopy
private T [] _createValueArray (@Nonnegative final int nSize)
{
final Object [] ret = new Object [nSize];
Arrays.fill (ret, NO_VALUE);
return GenericReflection.uncheckedCast (ret);
}
示例9: remove
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
public boolean remove (final Object aEntryObj)
{
if (!(aEntryObj instanceof Map.Entry <?, ?>))
return false;
final Map.Entry <K, V> aEntry = GenericReflection.uncheckedCast (aEntryObj);
return m_aSrcEntrySet.remove (new SoftMapEntry<> (aEntry.getKey (), aEntry.getValue (), m_aQueue));
}
示例10: testMicroTypeConversion
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
/**
* Test if the {@link MicroTypeConverter} is OK. It converts it to XML and
* back and than uses
* {@link CommonsTestHelper#testDefaultImplementationWithEqualContentObject(Object, Object)}
* to check for equality.
*
* @param <T>
* The data type to be used and returned
* @param aObj
* The object to test
* @return The object read after conversion
*/
public static <T> T testMicroTypeConversion (@Nonnull final T aObj)
{
assertNotNull (aObj);
// Write to XML
final IMicroElement e = MicroTypeConverter.convertToMicroElement (aObj, "test");
assertNotNull (e);
// Read from XML
final Object aObj2 = MicroTypeConverter.convertToNative (e, aObj.getClass ());
assertNotNull (aObj2);
// Write to XML again
final IMicroElement e2 = MicroTypeConverter.convertToMicroElement (aObj2, "test");
assertNotNull (e2);
// Ensure XML representation is identical
final String sXML1 = MicroWriter.getNodeAsString (e);
final String sXML2 = MicroWriter.getNodeAsString (e2);
CommonsTestHelper._assertEquals ("XML representation must be identical", sXML1, sXML2);
// Ensure they are equals
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aObj, aObj2);
return GenericReflection.uncheckedCast (aObj2);
}
示例11: getTypeConverter
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
@Nullable
public ITypeConverter <Object, Object> getTypeConverter (@Nonnull final Class <?> aSrcClass,
@Nonnull final Class <?> aDstClass)
{
return GenericReflection.uncheckedCast (TypeConverterRegistry.getInstance ().getFuzzyConverter (aSrcClass,
aDstClass));
}
示例12: getHashCode
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
public static int getHashCode (@Nullable final Object aObj)
{
if (aObj == null)
return HashCodeCalculator.HASHCODE_NULL;
// Get the best matching implementation
final Class <?> aClass = aObj.getClass ();
final IHashCodeImplementation <Object> aImpl = GenericReflection.uncheckedCast (getInstance ().getBestMatchingHashCodeImplementation (aClass));
return aImpl == null ? aObj.hashCode () : aImpl.getHashCode (aObj);
}
示例13: proxying
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
@Nonnull
public static <T> T proxying (@Nonnull final Class <? extends T> aInterfaceClass,
@Nonnull final T aActualTarget,
@Nonnull final Function <? super T, ? extends InvocationHandler> aFactory)
{
ValueEnforcer.isTrue (aInterfaceClass.isInterface (), "Only interface classes can be proxied!");
final Object ret = Proxy.newProxyInstance (aInterfaceClass.getClassLoader (),
new Class <?> [] { aInterfaceClass },
aFactory.apply (aActualTarget));
return GenericReflection.uncheckedCast (ret);
}
示例14: _processQueue
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
/**
* Here we go through the ReferenceQueue and remove garbage collected
* SoftValue objects from the HashMap by looking them up using the
* SoftValue.m_aKey data member.
*/
private void _processQueue ()
{
SoftValue <K, V> aSoftValue;
while ((aSoftValue = GenericReflection.uncheckedCast (m_aQueue.poll ())) != null)
{
m_aSrcMap.remove (aSoftValue.m_aKey);
}
}
示例15: getConverterToMicroElement
import com.helger.commons.lang.GenericReflection; //导入方法依赖的package包/类
@Nullable
public <T> IMicroTypeConverter <T> getConverterToMicroElement (@Nullable final Class <T> aSrcClass)
{
return GenericReflection.uncheckedCast (m_aRWLock.readLocked ( () -> m_aMap.get (aSrcClass)));
}