当前位置: 首页>>代码示例>>Java>>正文


Java GenericReflection.uncheckedCast方法代码示例

本文整理汇总了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);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:22,代码来源:RingBufferFifo.java

示例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);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:23,代码来源:RingBufferLifo.java

示例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);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:18,代码来源:AbstractSoftMap.java

示例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);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:19,代码来源:Dijkstra.java

示例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));
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:19,代码来源:XPathEvaluationHelper.java

示例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);
  }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:22,代码来源:SerializationConverter.java

示例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);
  }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:28,代码来源:SerializationHelper.java

示例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);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:9,代码来源:IntObjectMap.java

示例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));
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:8,代码来源:AbstractSoftMap.java

示例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);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:39,代码来源:XMLTestHelper.java

示例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));
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:8,代码来源:TypeConverterProviderFuzzy.java

示例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);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:11,代码来源:HashCodeImplementationRegistry.java

示例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);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:12,代码来源:LoggingInvocationHandler.java

示例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);
  }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:14,代码来源:AbstractSoftMap.java

示例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)));
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:6,代码来源:MicroTypeConverterRegistry.java


注:本文中的com.helger.commons.lang.GenericReflection.uncheckedCast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。