Package org.ec4j.core
Class ResourceProperties
java.lang.Object
org.ec4j.core.ResourceProperties
A collection of
Propertys applicable to a Resource as returned by
ResourcePropertiesService.queryProperties(Resource).
This is basically just a wrapper around a Map of Propertys that offers utility methods for getting
entries from the underlying Map not only by name but also by PropertyType in a type safe manner.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ResourceProperties.Builderbuilder()<T> TGets aPropertyfrompropertiesby the givennameand returnsProperty.getValueAs()or returnsdefaultValueif no suchnameis available inproperties.<T> TgetValue(PropertyType<T> type, T defaultValue, boolean throwInvalid) Gets aPropertyfrompropertiesby thenameof the givenPropertyTypeand returnsProperty.getValueAs()or returnsdefaultValueif no suchnameis available inproperties.
-
Field Details
-
properties
-
editorConfigFiles
-
-
Constructor Details
-
ResourceProperties
-
-
Method Details
-
builder
- Returns:
- a new
ResourceProperties.Builder
-
getProperties
-
getValue
Gets aPropertyfrompropertiesby thenameof the givenPropertyTypeand returnsProperty.getValueAs()or returnsdefaultValueif no suchnameis available inproperties.- Type Parameters:
T- the type of the property value- Parameters:
type- thePropertyTypewhosenamewill be used to get the value fronpropertiesdefaultValue- the value to return if thenameis not available inpropertiesthrowInvalid- iftrueand the underlyingPropertyvalue is invalid, anRuntimeExceptionwill be thrown. Otherwise, in the same case the invalid value will be ignored anddefaultValuewill be returned instead- Returns:
- the value associated with the given
type'snameor thedefaultValueif thenameis not available inproperties - Throws:
RuntimeException- ifthrowInvalidistrueand the underlyingPropertyvalue is invalid.
-
getValue
Gets aPropertyfrompropertiesby the givennameand returnsProperty.getValueAs()or returnsdefaultValueif no suchnameis available inproperties.- Type Parameters:
T- the type of the property value- Parameters:
name- the name to use to get the value fronpropertiesdefaultValue- the value to return if thenameis not available inpropertiesthrowInvalid- iftrueand the underlyingPropertyvalue is invalid, anRuntimeExceptionwill be thrown. Otherwise, in the same case the invalid value will be ignored anddefaultValuewill be returned instead- Returns:
- the value associated with the given
nameor thedefaultValueif thenameis not available inproperties - Throws:
RuntimeException- ifthrowInvalidistrueand the underlyingPropertyvalue is invalid.
-
getEditorConfigFiles
- Returns:
- a
ListofEc4jPaths pointing at.editorconfigfiles existing in the parent hierarchy of the queriedResource. The files are ordered from the.editorconfigfile closest to the queriedResourceto the root of the hierarchy. Only existing files are included. If some of the files in the hierarchy containsroot = true, then any other files higher in the hierarchy won't be returned. Any user and/or system defaults passed viaResourcePropertiesService.Builder.defaultEditorConfig(org.ec4j.core.model.EditorConfig)or related methods will not be included in the returned list.
-