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 class
FormatSharedNamesAndAppendUniqueStringToThoseWhichRepeat.Factory
-
Field Summary
Fields Modifier and Type Field Description protected char
delimiter
protected Validator<String>
groupValidator
protected String
prefix
protected String
sharedFormat
protected Pattern
sharedGroupPattern
protected com.google.common.base.Supplier<String>
suffixSupplier
protected String
uniqueFormat
protected Pattern
uniqueGroupPattern
-
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 String
checkGroup(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.String
extractGroup(String encoded)
Extracts the group from a shared/unique name.protected String
firstGroupInPatternOrNull(Pattern pattern, String encoded)
String
groupInSharedNameOrNull(String encoded)
retrieve the group associated with the encoded nameString
groupInUniqueNameOrNull(String encoded)
retrieve the group associated with the encoded nameString
sharedNameForGroup(String group)
encodes the {code group parameter} into a name that exists only once in the group.String
uniqueNameForGroup(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:GroupNamingConvention
encodes the {code group parameter} into a name that exists only once in the group.- Specified by:
sharedNameForGroup
in interfaceGroupNamingConvention
-
uniqueNameForGroup
public String uniqueNameForGroup(String group)
Description copied from interface:GroupNamingConvention
encodes 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:
uniqueNameForGroup
in interfaceGroupNamingConvention
-
groupInUniqueNameOrNull
public String groupInUniqueNameOrNull(String encoded)
Description copied from interface:GroupNamingConvention
retrieve the group associated with the encoded name- Specified by:
groupInUniqueNameOrNull
in interfaceGroupNamingConvention
-
firstGroupInPatternOrNull
protected String firstGroupInPatternOrNull(Pattern pattern, String encoded)
-
groupInSharedNameOrNull
public String groupInSharedNameOrNull(String encoded)
Description copied from interface:GroupNamingConvention
retrieve the group associated with the encoded name- Specified by:
groupInSharedNameOrNull
in interfaceGroupNamingConvention
-
containsGroup
public com.google.common.base.Predicate<String> containsGroup(String group)
Description copied from interface:GroupNamingConvention
A predicate that identifies if an input has the given group encoded in it.- Specified by:
containsGroup
in interfaceGroupNamingConvention
-
containsAnyGroup
public com.google.common.base.Predicate<String> containsAnyGroup()
Description copied from interface:GroupNamingConvention
A predicate that identifies if an input has any group encoded in it.- Specified by:
containsAnyGroup
in interfaceGroupNamingConvention
-
extractGroup
public String extractGroup(String encoded)
Description copied from interface:GroupNamingConvention
Extracts the group from a shared/unique name. Or returns null if not in correct format to contain a group.- Specified by:
extractGroup
in interfaceGroupNamingConvention
-
-