Package com._1c.g5.v8.dt.ui.util
Class Labeler
- java.lang.Object
-
- com._1c.g5.v8.dt.ui.util.Labeler
-
public class Labeler extends Object
Support class to build UI-representable labels for metadata objects or metadata object features. Supports:- Basic object label building, such as
Catalog
. - Path object label building, such as
Catalogs.Catalog1.Forms.Form1
.Labeler
is aware of current DT IDE locale and produce nodes with appropriate language.
Path will be constructed in the terms of 1C:Enterprise Navigator, including Navigator container nodes, such as
Catalogs
orForms
. Clients canfilter
unnecessary nodes and elements or define stop elements and conditions.Example of usage:
String pathLabel = Labeler.path(form, '.').skipCommonNode().stopBefore(IProject.class) .stopBefore(Configuration.class).label(); // pathLabel will be like "Catalogs.Catalog1.Forms.Form1" String basicLabel = Labeler.label(form); // basicLabel will be like "Form1"
Instances of ofLabeler
are stateful and not safe for use by multiple threads. - Basic object label building, such as
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Labeler
filter(Predicate<Object> filter)
Filter building label path elements with the given predicate.String
label()
Build path label.static String
label(Object object)
Returns basic label for a given object.static Labeler
path(Object object, char separator)
Returns label builder for the given object and path separator.static Labeler
path(Object object, String separator)
Returns label builder for the given object and path separator.Labeler
skipCommonNode()
Skip 1C:Enterprise Navigator "Common" node.Labeler
stopAfter(Class<?> stopAfter)
Stop label path bulding after path element will be instance of the given class.Labeler
stopAfter(Class<?> stopAfter, int fromIndex)
Stop label path bulding after path element will be instance of the given class.Labeler
stopAfter(Predicate<Object> stopAfter)
Stop label path bulding after path element will satisfy the given predicate.Labeler
stopBefore(Class<?> stopBefore)
Stop label path bulding when path element will be instance of the given class.Labeler
stopBefore(Predicate<Object> stopBefore)
Stop label path bulding when path element will satisfy the given predicate.
-
-
-
Method Detail
-
label
public static String label(Object object)
Returns basic label for a given object. Supports metadata objects, metadata object features or 1C:Enterprise Navigator nodes.- Parameters:
object
- the object to obtain label for, cannot benull
- Returns:
- obtained label or empty string if object has no label, never
null
-
path
public static Labeler path(Object object, char separator)
Returns label builder for the given object and path separator. Clients can configure label builder and build label withlabel()
method.Path will be constructed in the terms of 1C:Enterprise Navigator, including Navigator container nodes, such as
Catalogs
orForms
. Clients canfilter
unnecessary nodes and elements or define stop elements and conditions.- Parameters:
object
- the object to obtain path label for, cannot benull
separator
- the path separator to use, cannot benull
- Returns:
- the label builder, never
null
-
path
public static Labeler path(Object object, String separator)
Returns label builder for the given object and path separator. Clients can configure label builder and build label withlabel()
method.Path will be constructed in the terms of 1C:Enterprise Navigator, including Navigator container nodes, such as
Catalogs
orForms
. Clients canfilter
unnecessary nodes and elements or define stop elements and conditions.- Parameters:
object
- the object to obtain path label for, cannot benull
separator
- the path separator to use, cannot benull
- Returns:
- the label builder, never
null
-
filter
public Labeler filter(Predicate<Object> filter)
Filter building label path elements with the given predicate. AllLabeler
filter predicates will be combined with "and" operation.- Parameters:
filter
- the filter predicate to filter path elements, cannot benull
- Returns:
- a reference to this label builder, never
null
-
stopBefore
public Labeler stopBefore(Predicate<Object> stopBefore)
Stop label path bulding when path element will satisfy the given predicate. AllLabeler
stop-before predicates will be combined with "or" operation.- Parameters:
stopBefore
- the predicate to stop bulding path before, cannot benull
- Returns:
- a reference to this label builder, never
null
-
stopBefore
public Labeler stopBefore(Class<?> stopBefore)
Stop label path bulding when path element will be instance of the given class. AllLabeler
stop-before predicates will be combined with "or" operation.- Parameters:
stopBefore
- the class to stop bulding path before, cannot benull
- Returns:
- a reference to this label builder, never
null
-
stopAfter
public Labeler stopAfter(Predicate<Object> stopAfter)
Stop label path bulding after path element will satisfy the given predicate. AllLabeler
stop-after predicates will be combined with "or" operation.- Parameters:
stopAfter
- the predicate to stop bulding path after, cannot benull
- Returns:
- a reference to this label builder, never
null
-
stopAfter
public Labeler stopAfter(Class<?> stopAfter)
Stop label path bulding after path element will be instance of the given class. AllLabeler
stop-after predicates will be combined with "or" operation.- Parameters:
stopAfter
- the class to stop bulding path after, cannot benull
- Returns:
- a reference to this label builder, never
null
-
stopAfter
public Labeler stopAfter(Class<?> stopAfter, int fromIndex)
Stop label path bulding after path element will be instance of the given class. AllLabeler
stop-after predicates will be combined with "or" operation.- Parameters:
stopAfter
- the class to stop bulding path after, cannot benull
fromIndex
- the index of the occurrence of thestopAfter
to use to stop, must be positive- Returns:
- a reference to this label builder, never
null
-
skipCommonNode
public Labeler skipCommonNode()
Skip 1C:Enterprise Navigator "Common" node.- Returns:
- a reference to this label builder, never
null
-
label
public String label()
Build path label. Result may be used in UI representation.- Returns:
- the path label as
String
, nevernull
-
-