本文整理汇总了Java中com.helger.commons.id.IHasID类的典型用法代码示例。如果您正苦于以下问题:Java IHasID类的具体用法?Java IHasID怎么用?Java IHasID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IHasID类属于com.helger.commons.id包,在下文中一共展示了IHasID类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildTree
import com.helger.commons.id.IHasID; //导入依赖的package包/类
@Nonnull
public static <KEYTYPE, DATATYPE extends IHasID <KEYTYPE>> DefaultTreeWithID <KEYTYPE, DATATYPE> buildTree (@Nonnull final IChildrenProvider <DATATYPE> aChildrenResolver)
{
ValueEnforcer.notNull (aChildrenResolver, "ChildrenResolver");
final DefaultTreeWithID <KEYTYPE, DATATYPE> aTree = new DefaultTreeWithID <> ();
// get all root objects
if (aChildrenResolver.hasChildren (null))
for (final DATATYPE aRootObject : aChildrenResolver.getAllChildren (null))
{
// it is a root item
final DefaultTreeItemWithID <KEYTYPE, DATATYPE> aItem = aTree.getRootItem ().createChildItem (
aRootObject.getID (),
aRootObject);
_buildTreeRecursive (aItem, aChildrenResolver);
}
return aTree;
}
开发者ID:phax,项目名称:ph-commons,代码行数:20,代码来源:TreeWithIDBuilder.java
示例2: testAll
import com.helger.commons.id.IHasID; //导入依赖的package包/类
@Test
public void testAll ()
{
final ChildrenProviderSorting <MockHasChildren> cr = new ChildrenProviderSorting <> (new MockChildrenProvider (),
IHasID.getComparatorID ());
assertFalse (cr.hasChildren (null));
assertEquals (0, cr.getChildCount (null));
assertNull (cr.getAllChildren (null));
final MockHasChildren hca = new MockHasChildren ("a");
final MockHasChildren hcb = new MockHasChildren ("b");
final MockHasChildren hc1 = new MockHasChildren ("1", hcb, hca);
assertTrue (cr.hasChildren (hc1));
assertFalse (cr.hasChildren (hca));
assertEquals (2, cr.getChildCount (hc1));
assertEquals (0, cr.getChildCount (hca));
assertNotNull (cr.getAllChildren (hc1));
assertNotNull (cr.getAllChildren (hca));
}
开发者ID:phax,项目名称:ph-commons,代码行数:19,代码来源:ChildrenProviderSortingTest.java
示例3: testAll
import com.helger.commons.id.IHasID; //导入依赖的package包/类
@Test
public void testAll ()
{
final ChildrenProviderSortingWithID <String, MockHasChildren> cr = new ChildrenProviderSortingWithID <> (new MockChildrenProviderWithID (),
IHasID.getComparatorID ());
assertFalse (cr.hasChildren (null));
assertEquals (0, cr.getChildCount (null));
assertNull (cr.getAllChildren (null));
final MockHasChildren hca = new MockHasChildren ("a");
final MockHasChildren hcb = new MockHasChildren ("b");
final MockHasChildren hc1 = new MockHasChildren ("1", hcb, hca);
assertTrue (cr.hasChildren (hc1));
assertFalse (cr.hasChildren (hca));
assertEquals (2, cr.getChildCount (hc1));
assertEquals (0, cr.getChildCount (hca));
assertNotNull (cr.getAllChildren (hc1));
assertNotNull (cr.getAllChildren (hca));
assertSame (hca, cr.getChildWithID (hc1, "a"));
assertSame (hcb, cr.getChildWithID (hc1, "b"));
assertNull (cr.getChildWithID (hc1, "anyid"));
}
开发者ID:phax,项目名称:ph-commons,代码行数:22,代码来源:ChildrenProviderSortingWithIDTest.java
示例4: testAll
import com.helger.commons.id.IHasID; //导入依赖的package包/类
@Test
public void testAll ()
{
final ChildrenProviderHasChildrenSorting <MockHasChildren> cr = new ChildrenProviderHasChildrenSorting <> (IHasID.getComparatorID ());
assertFalse (cr.hasChildren (null));
assertEquals (0, cr.getChildCount (null));
assertNull (cr.getAllChildren (null));
final MockHasChildren hca = new MockHasChildren ("a");
final MockHasChildren hcb = new MockHasChildren ("b");
final MockHasChildren hc1 = new MockHasChildren ("1", hcb, hca);
assertTrue (cr.hasChildren (hc1));
assertFalse (cr.hasChildren (hca));
assertEquals (2, cr.getChildCount (hc1));
assertEquals (0, cr.getChildCount (hca));
assertNotNull (cr.getAllChildren (hc1));
assertNotNull (cr.getAllChildren (hca));
}
开发者ID:phax,项目名称:ph-commons,代码行数:18,代码来源:ChildrenProviderHasChildrenSortingTest.java
示例5: _buildTreeRecursive
import com.helger.commons.id.IHasID; //导入依赖的package包/类
private static <KEYTYPE, DATATYPE extends IHasID <KEYTYPE>> void _buildTreeRecursive (@Nullable final DefaultTreeItemWithID <KEYTYPE, DATATYPE> aParentItem,
@Nonnull final IChildrenProvider <DATATYPE> aChildrenResolver)
{
if (aParentItem != null)
{
final DATATYPE aParentObject = aParentItem.getData ();
if (aChildrenResolver.hasChildren (aParentObject))
for (final DATATYPE aChild : aChildrenResolver.getAllChildren (aParentObject))
{
final DefaultTreeItemWithID <KEYTYPE, DATATYPE> aItem = aParentItem.createChildItem (aChild.getID (), aChild);
_buildTreeRecursive (aItem, aChildrenResolver);
}
}
}
开发者ID:phax,项目名称:ph-commons,代码行数:15,代码来源:TreeWithIDBuilder.java
示例6: testReorderByKey
import com.helger.commons.id.IHasID; //导入依赖的package包/类
@Test
public void testReorderByKey ()
{
final DefaultTreeWithID <String, String> t = new DefaultTreeWithID <> ();
// root item
final DefaultTreeItemWithID <String, String> ti = t.getRootItem ().createChildItem ("root", "Hallo");
// no items yet....
assertFalse (ti.hasChildren ());
// add 2 items
assertNotNull (ti.createChildItem ("id2", "Welt2"));
assertNotNull (ti.createChildItem ("id1", "Welt1"));
assertTrue (ti.hasChildren ());
// check current order
assertEquals (2, ti.getChildCount ());
assertEquals ("id2", ti.getAllChildren ().get (0).getID ());
assertEquals ("Welt2", ti.getAllChildren ().get (0).getData ());
assertEquals ("id1", ti.getAllChildren ().get (1).getID ());
assertEquals ("Welt1", ti.getAllChildren ().get (1).getData ());
// reorder
ti.reorderChildrenByItems (IHasID.getComparatorID ());
// check new order
assertEquals (2, ti.getChildCount ());
assertEquals ("id1", ti.getAllChildren ().get (0).getID ());
assertEquals ("Welt1", ti.getAllChildren ().get (0).getData ());
assertEquals ("id2", ti.getAllChildren ().get (1).getID ());
assertEquals ("Welt2", ti.getAllChildren ().get (1).getData ());
}
开发者ID:phax,项目名称:ph-commons,代码行数:34,代码来源:DefaultTreeItemWithIDTest.java
示例7: testGetClassHierarchy
import com.helger.commons.id.IHasID; //导入依赖的package包/类
@Test
public void testGetClassHierarchy ()
{
// Very basic class
Collection <Class <?>> aHierarchy = ClassHierarchyCache.getClassHierarchy (Object.class);
assertEquals (1, aHierarchy.size ());
assertTrue (aHierarchy.contains (Object.class));
// More sophisticated static class (no interfaces)
aHierarchy = ClassHierarchyCache.getClassHierarchy (CGlobal.class);
// Is usually 2, but with Cobertura enabled, it is 3!
assertTrue (aHierarchy.size () >= 2);
assertTrue (aHierarchy.contains (CGlobal.class));
assertTrue (aHierarchy.contains (Object.class));
// More sophisticated static class (with interfaces)
aHierarchy = ClassHierarchyCache.getClassHierarchy (TypedObject.class);
assertTrue (aHierarchy.size () >= 6);
assertTrue (aHierarchy.contains (TypedObject.class));
assertTrue (aHierarchy.contains (IHasObjectType.class));
assertTrue (aHierarchy.contains (ITypedObject.class));
assertTrue (aHierarchy.contains (IHasID.class));
assertTrue (aHierarchy.contains (Object.class));
assertTrue (aHierarchy.contains (Serializable.class));
try
{
ClassHierarchyCache.getClassHierarchy (null);
fail ();
}
catch (final NullPointerException ex)
{}
}
开发者ID:phax,项目名称:ph-commons,代码行数:34,代码来源:ClassHierarchyCacheTest.java
示例8: ForkedJvmPGCC
import com.helger.commons.id.IHasID; //导入依赖的package包/类
public ForkedJvmPGCC ()
{
addClassPathEntry (IHasID.class);
addClassPathEntry (EMessageDigestAlgorithm.class);
addClassPathEntry (LoggerFactory.class);
addClassPathEntry (Nullable.class);
}
开发者ID:phax,项目名称:ph-javacc-maven-plugin,代码行数:8,代码来源:ForkedJvmPGCC.java
示例9: MockHasSortedChildren
import com.helger.commons.id.IHasID; //导入依赖的package包/类
public MockHasSortedChildren (@Nonnull final String sID, @Nullable final MockHasSortedChildren... aList)
{
m_sID = sID;
m_aList = CollectionHelper.getSorted (aList, IHasID.getComparatorID ());
}
开发者ID:phax,项目名称:ph-commons,代码行数:6,代码来源:MockHasSortedChildren.java
示例10: getTreeWithStringIDAsXML
import com.helger.commons.id.IHasID; //导入依赖的package包/类
/**
* Specialized conversion method for converting a tree with ID to a
* standardized XML tree.
*
* @param <DATATYPE>
* tree item value type
* @param <ITEMTYPE>
* tree item type
* @param aTree
* The tree to be converted
* @param aConverter
* The main data converter that converts the tree item values into XML
* @return The created document.
*/
@Nonnull
public static <DATATYPE, ITEMTYPE extends ITreeItemWithID <String, DATATYPE, ITEMTYPE>> IMicroElement getTreeWithStringIDAsXML (@Nonnull final IBasicTree <DATATYPE, ITEMTYPE> aTree,
@Nonnull final IConverterTreeItemToMicroNode <? super DATATYPE> aConverter)
{
return getTreeWithIDAsXML (aTree, IHasID.getComparatorID (), Function.identity (), aConverter);
}
开发者ID:phax,项目名称:ph-commons,代码行数:21,代码来源:TreeXMLConverter.java
示例11: getFromIDOrNull
import com.helger.commons.id.IHasID; //导入依赖的package包/类
/**
* Get the enum value with the passed ID
*
* @param <KEYTYPE>
* The ID type
* @param <ENUMTYPE>
* The enum type
* @param aClass
* The enum class
* @param aID
* The ID to search
* @return <code>null</code> if no enum item with the given ID is present.
*/
@Nullable
public static <KEYTYPE, ENUMTYPE extends Enum <ENUMTYPE> & IHasID <KEYTYPE>> ENUMTYPE getFromIDOrNull (@Nonnull final Class <ENUMTYPE> aClass,
@Nullable final KEYTYPE aID)
{
return getFromIDOrDefault (aClass, aID, null);
}
开发者ID:phax,项目名称:ph-commons,代码行数:20,代码来源:EnumHelper.java
示例12: getFromIDOrDefault
import com.helger.commons.id.IHasID; //导入依赖的package包/类
/**
* Get the enum value with the passed ID
*
* @param <KEYTYPE>
* The ID type
* @param <ENUMTYPE>
* The enum type
* @param aClass
* The enum class
* @param aID
* The ID to search
* @param eDefault
* The default value to be returned, if the ID was not found.
* @return The default parameter if no enum item with the given ID is present.
*/
@Nullable
public static <KEYTYPE, ENUMTYPE extends Enum <ENUMTYPE> & IHasID <KEYTYPE>> ENUMTYPE getFromIDOrDefault (@Nonnull final Class <ENUMTYPE> aClass,
@Nullable final KEYTYPE aID,
@Nullable final ENUMTYPE eDefault)
{
ValueEnforcer.notNull (aClass, "Class");
if (aID == null)
return eDefault;
return findFirst (aClass, x -> x.getID ().equals (aID), eDefault);
}
开发者ID:phax,项目名称:ph-commons,代码行数:27,代码来源:EnumHelper.java
示例13: getFromIDOrThrow
import com.helger.commons.id.IHasID; //导入依赖的package包/类
/**
* Get the enum value with the passed ID. If no such ID is present, an
* {@link IllegalArgumentException} is thrown.
*
* @param <KEYTYPE>
* The ID type
* @param <ENUMTYPE>
* The enum type
* @param aClass
* The enum class
* @param aID
* The ID to search
* @return The enum item with the given ID. Never <code>null</code>.
* @throws IllegalArgumentException
* if no enum item with the given ID is present
*/
@Nonnull
public static <KEYTYPE, ENUMTYPE extends Enum <ENUMTYPE> & IHasID <KEYTYPE>> ENUMTYPE getFromIDOrThrow (@Nonnull final Class <ENUMTYPE> aClass,
@Nullable final KEYTYPE aID)
{
final ENUMTYPE aEnum = getFromIDOrNull (aClass, aID);
if (aEnum == null)
throw new IllegalArgumentException ("Failed to resolve ID " + aID + " within class " + aClass);
return aEnum;
}
开发者ID:phax,项目名称:ph-commons,代码行数:26,代码来源:EnumHelper.java
示例14: getFromIDCaseInsensitiveOrNull
import com.helger.commons.id.IHasID; //导入依赖的package包/类
/**
* Get the enum value with the passed string ID case insensitive
*
* @param <ENUMTYPE>
* The enum type
* @param aClass
* The enum class
* @param sID
* The ID to search
* @return <code>null</code> if no enum item with the given ID is present.
*/
@Nullable
public static <ENUMTYPE extends Enum <ENUMTYPE> & IHasID <String>> ENUMTYPE getFromIDCaseInsensitiveOrNull (@Nonnull final Class <ENUMTYPE> aClass,
@Nullable final String sID)
{
return getFromIDCaseInsensitiveOrDefault (aClass, sID, null);
}
开发者ID:phax,项目名称:ph-commons,代码行数:18,代码来源:EnumHelper.java
示例15: getFromIDCaseInsensitiveOrDefault
import com.helger.commons.id.IHasID; //导入依赖的package包/类
/**
* Get the enum value with the passed string ID case insensitive
*
* @param <ENUMTYPE>
* The enum type
* @param aClass
* The enum class
* @param sID
* The ID to search
* @param eDefault
* The default value to be returned, if the ID was not found.
* @return The default parameter if no enum item with the given ID is present.
*/
@Nullable
public static <ENUMTYPE extends Enum <ENUMTYPE> & IHasID <String>> ENUMTYPE getFromIDCaseInsensitiveOrDefault (@Nonnull final Class <ENUMTYPE> aClass,
@Nullable final String sID,
@Nullable final ENUMTYPE eDefault)
{
ValueEnforcer.notNull (aClass, "Class");
if (sID == null)
return eDefault;
return findFirst (aClass, x -> x.getID ().equalsIgnoreCase (sID), eDefault);
}
开发者ID:phax,项目名称:ph-commons,代码行数:25,代码来源:EnumHelper.java
示例16: getFromIDCaseInsensitiveOrThrow
import com.helger.commons.id.IHasID; //导入依赖的package包/类
/**
* Get the enum value with the passed string ID (case insensitive). If no such
* ID is present, an {@link IllegalArgumentException} is thrown.
*
* @param <ENUMTYPE>
* The enum type
* @param aClass
* The enum class
* @param sID
* The ID to search
* @return The enum item with the given ID. Never <code>null</code>.
* @throws IllegalArgumentException
* if no enum item with the given ID is present
*/
@Nonnull
public static <ENUMTYPE extends Enum <ENUMTYPE> & IHasID <String>> ENUMTYPE getFromIDCaseInsensitiveOrThrow (@Nonnull final Class <ENUMTYPE> aClass,
@Nullable final String sID)
{
final ENUMTYPE aEnum = getFromIDCaseInsensitiveOrNull (aClass, sID);
if (aEnum == null)
throw new IllegalArgumentException ("Failed to resolve ID " + sID + " within class " + aClass);
return aEnum;
}
开发者ID:phax,项目名称:ph-commons,代码行数:24,代码来源:EnumHelper.java
示例17: sortByID
import com.helger.commons.id.IHasID; //导入依赖的package包/类
/**
* Sort each level of the passed tree on the ID with the specified comparator.
*
* @param <KEYTYPE>
* Tree item key type
* @param <DATATYPE>
* Tree item data type
* @param <ITEMTYPE>
* Tree item type
* @param aTree
* The tree to be sorted.
* @param aKeyComparator
* The comparator to be used for sorting the tree item keys on each
* level.
*/
public static <KEYTYPE, DATATYPE, ITEMTYPE extends ITreeItemWithID <KEYTYPE, DATATYPE, ITEMTYPE>> void sortByID (@Nonnull final IBasicTree <DATATYPE, ITEMTYPE> aTree,
@Nonnull final Comparator <? super KEYTYPE> aKeyComparator)
{
_sort (aTree, Comparator.comparing (IHasID::getID, aKeyComparator));
}
开发者ID:phax,项目名称:ph-commons,代码行数:21,代码来源:TreeWithIDSorter.java
注:本文中的com.helger.commons.id.IHasID类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论