Package com.facebook.buck.rules.macros
Class StringWithMacros
- java.lang.Object
-
- com.facebook.buck.rules.macros.StringWithMacros
-
- All Implemented Interfaces:
StringMatcher
,TargetTranslatable<StringWithMacros>
public abstract class StringWithMacros extends Object implements TargetTranslatable<StringWithMacros>, StringMatcher
A class representing a string containing ordered, embedded, strongly typed macros.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
String
format(java.util.function.Function<? super MacroContainer,? extends CharSequence> mapper)
com.google.common.collect.ImmutableList<MacroContainer>
getMacros()
abstract com.google.common.collect.ImmutableList<Either<String,MacroContainer>>
getParts()
The components of the macro string.int
hashCode()
<T> com.google.common.collect.ImmutableList<T>
map(java.util.function.Function<? super String,? extends T> stringMapper, java.util.function.Function<? super MacroContainer,? extends T> macroMapper)
StringWithMacros
mapStrings(java.util.function.Function<String,String> mapper)
boolean
matches(String s)
static StringWithMacros
of(com.google.common.collect.ImmutableList<Either<String,MacroContainer>> parts)
String with macros is a sequence of strings and macros.static StringWithMacros
ofConstantString(String singlePart)
Create a string with macros with a single string without macrosOptional<StringWithMacros>
translateTargets(CellNameResolver cellPathResolver, BaseName targetBaseName, TargetNodeTranslator translator)
-
-
-
Method Detail
-
getParts
public abstract com.google.common.collect.ImmutableList<Either<String,MacroContainer>> getParts()
The components of the macro string. Each part is either a plain string or a macro.
-
of
public static StringWithMacros of(com.google.common.collect.ImmutableList<Either<String,MacroContainer>> parts)
String with macros is a sequence of strings and macros. Create it.
-
ofConstantString
public static StringWithMacros ofConstantString(String singlePart)
Create a string with macros with a single string without macros
-
getMacros
public com.google.common.collect.ImmutableList<MacroContainer> getMacros()
- Returns:
- the list of all
Macro
s in the macro string.
-
map
public <T> com.google.common.collect.ImmutableList<T> map(java.util.function.Function<? super String,? extends T> stringMapper, java.util.function.Function<? super MacroContainer,? extends T> macroMapper)
-
format
public String format(java.util.function.Function<? super MacroContainer,? extends CharSequence> mapper)
-
mapStrings
public StringWithMacros mapStrings(java.util.function.Function<String,String> mapper)
- Returns:
- a new
StringWithMacros
with the string components transformed bymapper
.
-
translateTargets
public Optional<StringWithMacros> translateTargets(CellNameResolver cellPathResolver, BaseName targetBaseName, TargetNodeTranslator translator)
- Specified by:
translateTargets
in interfaceTargetTranslatable<StringWithMacros>
- Returns:
- if any changes are required, return the translated object.
-
matches
public boolean matches(String s)
- Specified by:
matches
in interfaceStringMatcher
-
-