org.jclouds.compute.internal
Class FormatSharedNamesAndAppendUniqueStringToThoseWhichRepeat

java.lang.Object
  extended by 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
static class FormatSharedNamesAndAppendUniqueStringToThoseWhichRepeat.Factory
           
 
Field Summary
protected  char delimiter
           
protected  org.jclouds.predicates.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
FormatSharedNamesAndAppendUniqueStringToThoseWhichRepeat(String prefix, char delimiter, com.google.common.base.Supplier<String> suffixSupplier, org.jclouds.predicates.Validator<String> groupValidator)
           
 
Method Summary
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 name
 String groupInUniqueNameOrNull(String encoded)
          retrieve the group associated with the encoded name
 String 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

groupValidator

protected final org.jclouds.predicates.Validator<String> groupValidator
Constructor Detail

FormatSharedNamesAndAppendUniqueStringToThoseWhichRepeat

public FormatSharedNamesAndAppendUniqueStringToThoseWhichRepeat(String prefix,
                                                                char delimiter,
                                                                com.google.common.base.Supplier<String> suffixSupplier,
                                                                org.jclouds.predicates.Validator<String> groupValidator)
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 interface GroupNamingConvention

checkGroup

protected String checkGroup(String group)

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 interface GroupNamingConvention

groupInUniqueNameOrNull

public String groupInUniqueNameOrNull(String encoded)
Description copied from interface: GroupNamingConvention
retrieve the group associated with the encoded name

Specified by:
groupInUniqueNameOrNull in interface GroupNamingConvention

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 interface GroupNamingConvention

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 interface GroupNamingConvention

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 interface GroupNamingConvention

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 interface GroupNamingConvention


Copyright © 2009-2014 The Apache Software Foundation. All Rights Reserved.