|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openpermis.policy.bean.basic.BasicUtilities
public final class BasicUtilities
Helper functions for part implementations.
Nested Class Summary | |
---|---|
static class |
BasicUtilities.DetailsProvider<T>
Provides string details about an item. |
Field Summary | |
---|---|
static int |
NOT_FOUND
Constant used by list functions to indicate that no entry could be found. |
Method Summary | ||
---|---|---|
static
|
assertListIsLegal(PartBean owner,
String type,
List<T> list)
Asserts that the list specified is legal. |
|
static boolean |
equalLists(List<?> list1,
List<?> list2)
Compares two lists without respecting the list order. |
|
static boolean |
equalObjects(Object obj1,
Object obj2)
Convenience function to test if two objects are both null or equivalent. |
|
static
|
findDuplicateListEntry(List<T> list)
Finds the position of the first entry which is contained twice. |
|
static
|
findDuplicateSerialNumberInList(List<T> list)
Finds the position of the first entry with a duplicate serial number. |
|
static
|
findInvalidSerialNumberInList(List<T> list,
SerialNumber context)
Finds the position of the first entry with an invalid serial number. |
|
static
|
findNullListEntry(List<T> list)
Finds the first entry which is null . |
|
static
|
getDetails(Iterable<T> collection,
BasicUtilities.DetailsProvider<T> provider)
Returns the details for the specified collection using the provider passed. |
|
static String |
getIdentityDetails(Identifiable item)
Returns the identity of the specified part item. |
|
static
|
getIdentityDetails(Iterable<T> collection)
Returns the string details representation for the specified collection. |
|
static
|
getNameDetails(Iterable<T> collection)
Returns the string details representation for the specified collection. |
|
static String |
getNameDetails(Nameable item)
Returns the name of the specified part item. |
|
static
|
getShortStringDetails(Iterable<T> collection)
Returns the string details representation for the specified collection. |
|
static
|
getStringDetails(Iterable<T> collection)
Returns the string details representation for the specified collection. |
|
static int |
listHashCode(Iterator<?> iterator)
Computes the hash code of a list without respecting the list order. |
|
static int |
listHashCode(List<?> list)
Computes the hash code of a list without respecting the list order. |
|
static int |
multiHashCode(int... values)
Convenience function to create a hash code by combining several other hash code values. |
|
static
|
validateListIdentities(PartProblemReporter reporter,
Part owner,
String type,
List<T> list)
Validates all identities in the specified list. |
|
static
|
validateListNames(PartProblemReporter reporter,
Part owner,
String type,
List<T> list)
Validates all names in the specified list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NOT_FOUND
-1
Method Detail |
---|
public static final int multiHashCode(int... values)
Use this method instead of combining multiple hash codes yourself. This method provides a suitable distribution of hash codes.
values
- the values to combine.
public static final int listHashCode(List<?> list)
Use if a list is used as if it were a set
that allows multiple
objects that are equal
.
equalLists(List, List)
!list
- the list for which to compute the hash code.
equalLists(List, List)
public static final int listHashCode(Iterator<?> iterator)
Use if a list is used as if it were a set
that allows multiple
objects that are equal
.
equalLists(List, List)
!iterator
- the iterator for which to compute the hash code.
equalLists(List, List)
public static final boolean equalLists(List<?> list1, List<?> list2)
Use if a list is used as if it were a set
that allows multiple
objects that are equal
.
listHashCode(List)
!list1
- the first list.list2
- the second list.
true
if the two lists have an equivalent content, disregarding the order
of their entries.public static final boolean equalObjects(Object obj1, Object obj2)
null
or equivalent.
obj1
- the first object.obj2
- the second object.
true
if both objects are null
or equivalent.public static <T extends PartBean> void assertListIsLegal(PartBean owner, String type, List<T> list) throws IllegalArgumentException
Lists are considered legal if the following conditions are met:
null
.null
entries.owner
specified is not null
and has a well-defined serial number).
T
- the type of the list to validate.owner
- the part that owns (or will own) the list, may be null
.type
- the type of list (used in exceptions thrown), may be null
.list
- the list to validate. may be null
.
IllegalArgumentException
- thrown if any of the conditions listed above is violated.public static <T> int findNullListEntry(List<T> list)
null
.
T
- the type of the list to search.list
- the list to search.
NOT_FOUND
if there is no such entry.public static <T> int findDuplicateListEntry(List<T> list)
Comparison is done by comparing the object identity (==
).
T
- the type of the list to search.list
- the list to search.
NOT_FOUND
if there is no such entry.public static <T extends PartBean> int findDuplicateSerialNumberInList(List<T> list)
T
- the type of the list to search.list
- the list to search.
NOT_FOUND
if there is no such entry.public static <T extends PartBean> int findInvalidSerialNumberInList(List<T> list, SerialNumber context)
An entry is considered to have an invalid serial number if:
null
.SerialNumber.UNDEFINED
serial numbers are ignored.
T
- the type of the list to search.list
- the list to search.context
- the serial number whose context is to be matched, must not be
null
and must not be SerialNumber.UNDEFINED
.
NOT_FOUND
if there is no such entry.public static <T extends Nameable> boolean validateListNames(PartProblemReporter reporter, Part owner, String type, List<T> list)
Entries with duplicate names are reported using the specified reporter.
T
- the type of list to validate.reporter
- the reporter to use, may be null
.owner
- the owner used when reporting problems.type
- the type used when reporting problems.list
- the list to validate, must not be null
.
true
if there are no duplicate names in the list.public static <T extends Identifiable> boolean validateListIdentities(PartProblemReporter reporter, Part owner, String type, List<T> list)
Entries with duplicate identities are reported using the specified reporter.
T
- the type of list to validate.reporter
- the reporter to use, may be null
.owner
- the owner used when reporting problems.type
- the type used when reporting problems.list
- the list to validate, must not be null
.
true
if there are no duplicate identities in the list.public static <T> String getDetails(Iterable<T> collection, BasicUtilities.DetailsProvider<T> provider)
The collection is surrounded by curly brackets to indicate that it's a collection.
T
- the type of collection to process.collection
- the collection to process.provider
- the provider to use for string details.
public static <T> String getStringDetails(Iterable<T> collection)
The details are created using Object.toString()
of the items.
T
- the type of collection to process.collection
- the collection to process.
public static <T extends PartBean> String getShortStringDetails(Iterable<T> collection)
The details are created using Object.toString()
of the items.
T
- the type of collection to process.collection
- the collection to process.
public static <T extends Identifiable> String getIdentityDetails(Iterable<T> collection)
The details are created using the Identifiable.getIdentity()
of the items.
T
- the type of collection to process.collection
- the collection to process.
public static <T extends Nameable> String getNameDetails(Iterable<T> collection)
The details are created using the Nameable.getName()
of the items.
T
- the type of collection to process.collection
- the collection to process.
public static String getIdentityDetails(Identifiable item)
The value is returned in square brackets to indicate that it's an object.
item
- the item to inspect, may be null
.
null
if the item specified is null.public static String getNameDetails(Nameable item)
The value is returned in curly brackets to indicate that it's an object.
item
- the item to inspect, may be null
.
null
if the item specified is null.
|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
PERMIS Role Based Access Control 0.4.0 (Build 15)
2009/05/20 08:14:49
Copyright (c) 2002-2007 Ergon Informatik AG