Package org.jclouds.compute.internal
Class FormatSharedNamesAndAppendUniqueStringToThoseWhichRepeat
- java.lang.Object
-
- org.jclouds.compute.internal.FormatSharedNamesAndAppendUniqueStringToThoseWhichRepeat
-
- All Implemented Interfaces:
GroupNamingConvention
public class FormatSharedNamesAndAppendUniqueStringToThoseWhichRepeat extends Object implements GroupNamingConvention
Get a name using a random mechanism that still ties all nodes in a group together. This implementation will pass the group and a hex formatted random number to the configured naming convention.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFormatSharedNamesAndAppendUniqueStringToThoseWhichRepeat.Factory
-
Field Summary
Fields Modifier and Type Field Description protected chardelimiterprotected Validator<String>groupValidatorprotected Stringprefixprotected StringsharedFormatprotected PatternsharedGroupPatternprotected com.google.common.base.Supplier<String>suffixSupplierprotected StringuniqueFormatprotected PatternuniqueGroupPattern
-
Constructor Summary
Constructors Constructor Description FormatSharedNamesAndAppendUniqueStringToThoseWhichRepeat(String prefix, char delimiter, com.google.common.base.Supplier<String> suffixSupplier, Validator<String> groupValidator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringcheckGroup(String group)com.google.common.base.Predicate<String>containsAnyGroup()A predicate that identifies if an input has any group encoded in it.com.google.common.base.Predicate<String>containsGroup(String group)A predicate that identifies if an input has the given group encoded in it.StringextractGroup(String encoded)Extracts the group from a shared/unique name.protected StringfirstGroupInPatternOrNull(Pattern pattern, String encoded)StringgroupInSharedNameOrNull(String encoded)retrieve the group associated with the encoded nameStringgroupInUniqueNameOrNull(String encoded)retrieve the group associated with the encoded nameStringsharedNameForGroup(String group)encodes the {code group parameter} into a name that exists only once in the group.StringuniqueNameForGroup(String group)encodes the {code group parameter} into a name that exists more than once in the group.
-
-
-
Field Detail
-
prefix
protected final String prefix
-
delimiter
protected final char delimiter
-
suffixSupplier
protected final com.google.common.base.Supplier<String> suffixSupplier
-
sharedFormat
protected final String sharedFormat
-
uniqueFormat
protected final String uniqueFormat
-
uniqueGroupPattern
protected final Pattern uniqueGroupPattern
-
sharedGroupPattern
protected final Pattern sharedGroupPattern
-
-
Method Detail
-
sharedNameForGroup
public String sharedNameForGroup(String group)
Description copied from interface:GroupNamingConventionencodes the {code group parameter} into a name that exists only once in the group.- Specified by:
sharedNameForGroupin interfaceGroupNamingConvention
-
uniqueNameForGroup
public String uniqueNameForGroup(String group)
Description copied from interface:GroupNamingConventionencodes the {code group parameter} into a name that exists more than once in the group.note
Do not expect this name to be guaranteed unique, though a good implementation should guess a unique name in one or two tries.- Specified by:
uniqueNameForGroupin interfaceGroupNamingConvention
-
groupInUniqueNameOrNull
public String groupInUniqueNameOrNull(String encoded)
Description copied from interface:GroupNamingConventionretrieve the group associated with the encoded name- Specified by:
groupInUniqueNameOrNullin interfaceGroupNamingConvention
-
firstGroupInPatternOrNull
protected String firstGroupInPatternOrNull(Pattern pattern, String encoded)
-
groupInSharedNameOrNull
public String groupInSharedNameOrNull(String encoded)
Description copied from interface:GroupNamingConventionretrieve the group associated with the encoded name- Specified by:
groupInSharedNameOrNullin interfaceGroupNamingConvention
-
containsGroup
public com.google.common.base.Predicate<String> containsGroup(String group)
Description copied from interface:GroupNamingConventionA predicate that identifies if an input has the given group encoded in it.- Specified by:
containsGroupin interfaceGroupNamingConvention
-
containsAnyGroup
public com.google.common.base.Predicate<String> containsAnyGroup()
Description copied from interface:GroupNamingConventionA predicate that identifies if an input has any group encoded in it.- Specified by:
containsAnyGroupin interfaceGroupNamingConvention
-
extractGroup
public String extractGroup(String encoded)
Description copied from interface:GroupNamingConventionExtracts the group from a shared/unique name. Or returns null if not in correct format to contain a group.- Specified by:
extractGroupin interfaceGroupNamingConvention
-
-