Class BeanParserUtils
- java.lang.Object
-
- com.hybris.cockpitng.core.util.bean.schema.BeanParserUtils
-
public final class BeanParserUtils extends java.lang.ObjectUtilities class that contains methods useful for spring namespaceBeanDefinitionParser.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classBeanParserUtils.NodeIterable<E extends org.w3c.dom.Node>protected static classBeanParserUtils.NodeIterableList<E extends org.w3c.dom.Node>protected static classBeanParserUtils.NodeIterator<E extends org.w3c.dom.Node>
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Optional<java.lang.String>getAttributeValue(org.w3c.dom.Node node, java.lang.String attributeName)Gets an attribute's value if it exists.static java.util.Optional<org.w3c.dom.Element>getChild(org.w3c.dom.Element parent, java.lang.String nodeName, int index)Gets a child element of specified name if it exists.static java.lang.Iterable<org.w3c.dom.Element>getChildren(org.w3c.dom.Element parent)Gets all children of typeElementfrom specified parent element.static java.util.List<org.w3c.dom.Element>getChildren(org.w3c.dom.Element parent, java.lang.String nodeName)Gets all children from specified element of provided name.static java.lang.Iterable<org.w3c.dom.Node>getChildren(org.w3c.dom.Element parent, java.util.function.Predicate<org.w3c.dom.Node> filter)Gets all children from specified parent element that satisfies provided condition.static java.util.List<org.w3c.dom.Node>getChildrenNodes(org.w3c.dom.Element parent)Gets all children from specified parent element.static <V,M>
java.util.function.Consumer<V>getConsumer(java.util.function.Function<V,M> mapper, java.util.function.Consumer<M> consumer)Creates a consumer that processes provided value and passes its result to provided consumer.static <V,M>
java.util.function.Consumer<V>getConsumer(java.util.function.Function<V,M> mapper, java.util.function.Consumer<M> consumer, java.util.function.Predicate<M> filter)Creates a consumer that processes provided value and passes its result to provided consumer if it matches provided restrictions.static java.util.Optional<org.w3c.dom.Element>getFirstChild(org.w3c.dom.Element parent, java.lang.String nodeName)Gets first child element of specified name if it exists.static <V,M>
voidmapAndConsume(java.util.Optional<V> value, java.util.function.Function<V,M> mapper, java.util.function.Consumer<M> consumer)Method for all situations matching the following flow: check if value is present inOptionalobject if value is present, then process it somehow pass processed value to final consumerstatic <V,M>
voidmapAndConsume(java.util.Optional<V> value, java.util.function.Function<V,M> mapper, java.util.function.Consumer<M> consumer, java.util.function.Predicate<M> filter)Method for all situations matching the following flow: check if value is present inOptionalobject if value is present, then process it somehow check if process result meets some restrictions pass processed value to final consumer
-
-
-
Method Detail
-
mapAndConsume
public static <V,M> void mapAndConsume(java.util.Optional<V> value, java.util.function.Function<V,M> mapper, java.util.function.Consumer<M> consumer)Method for all situations matching the following flow:- check if value is present in
Optionalobject - if value is present, then process it somehow
- pass processed value to final consumer
Most common use case is - acquire a
Node, get it's value if exists, parse it, change bean definition with parse result.- Type Parameters:
V- type of original valueM- type of processed value- Parameters:
value- value to be processed and consumedmapper- processing functionconsumer- final value consumer
- check if value is present in
-
mapAndConsume
public static <V,M> void mapAndConsume(java.util.Optional<V> value, java.util.function.Function<V,M> mapper, java.util.function.Consumer<M> consumer, java.util.function.Predicate<M> filter)Method for all situations matching the following flow:- check if value is present in
Optionalobject - if value is present, then process it somehow
- check if process result meets some restrictions
- pass processed value to final consumer
Most common use case is - acquire a
Node, get it's value if exists, parse it, check some condition, change bean definition with parse result if condition is satisfied.- Type Parameters:
V- type of original valueM- type of processed value- Parameters:
value- value to be processed and consumedmapper- processing functionfilter- condition that needs to be satisfied by processed value for it to be consumedconsumer- final value consumer
- check if value is present in
-
getConsumer
public static <V,M> java.util.function.Consumer<V> getConsumer(java.util.function.Function<V,M> mapper, java.util.function.Consumer<M> consumer)Creates a consumer that processes provided value and passes its result to provided consumer.- Type Parameters:
V- type of original valueM- type of processed value- Parameters:
mapper- processing methodconsumer- final value consumer- Returns:
- consumer
-
getConsumer
public static <V,M> java.util.function.Consumer<V> getConsumer(java.util.function.Function<V,M> mapper, java.util.function.Consumer<M> consumer, java.util.function.Predicate<M> filter)Creates a consumer that processes provided value and passes its result to provided consumer if it matches provided restrictions.- Type Parameters:
V- type of original valueM- type of processed value- Parameters:
mapper- processing methodconsumer- final value consumerfilter- condition that needs to be satisfied by processed value for it to be consumed- Returns:
- consumer
-
getAttributeValue
public static java.util.Optional<java.lang.String> getAttributeValue(org.w3c.dom.Node node, java.lang.String attributeName)Gets an attribute's value if it exists.- Parameters:
node- element which attribute is to be readattributeName- name of attribute to read- Returns:
- a value of attribute or
emptyif not available
-
getFirstChild
public static java.util.Optional<org.w3c.dom.Element> getFirstChild(org.w3c.dom.Element parent, java.lang.String nodeName)Gets first child element of specified name if it exists.- Parameters:
parent- parent elementnodeName- name of child- Returns:
- a child element or
emptyif not available
-
getChild
public static java.util.Optional<org.w3c.dom.Element> getChild(org.w3c.dom.Element parent, java.lang.String nodeName, int index)Gets a child element of specified name if it exists.- Parameters:
parent- parent elementnodeName- name of childindex- index of a child among all children of this name- Returns:
- a child element or
emptyif not available
-
getChildrenNodes
public static java.util.List<org.w3c.dom.Node> getChildrenNodes(org.w3c.dom.Element parent)
Gets all children from specified parent element.- Parameters:
parent- parent element- Returns:
- list of children
-
getChildren
public static java.util.List<org.w3c.dom.Element> getChildren(org.w3c.dom.Element parent, java.lang.String nodeName)Gets all children from specified element of provided name.- Parameters:
parent- parent elementnodeName- name of children to be found- Returns:
- list of children
-
getChildren
public static java.lang.Iterable<org.w3c.dom.Element> getChildren(org.w3c.dom.Element parent)
Gets all children of typeElementfrom specified parent element.- Parameters:
parent- parent element- Returns:
- list of children
-
getChildren
public static java.lang.Iterable<org.w3c.dom.Node> getChildren(org.w3c.dom.Element parent, java.util.function.Predicate<org.w3c.dom.Node> filter)Gets all children from specified parent element that satisfies provided condition.- Parameters:
parent- parent elementfilter- condition that must be satisfied by child node- Returns:
- list of children
-
-