SLING-12186 PoC for spotless-maven-plugin
diff --git a/pom.xml b/pom.xml
index c9e6be9..fdfcf4f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -33,68 +33,13 @@
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git</developerConnection>
- <url>https://github.com/apache/sling-org-apache-sling-models-impl.git</url>
<tag>HEAD</tag>
+ <url>https://github.com/apache/sling-org-apache-sling-models-impl.git</url>
</scm>
<properties>
<sling.java.version>8</sling.java.version>
<project.build.outputTimestamp>2023-05-30T08:54:10Z</project.build.outputTimestamp>
</properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <createSourcesJar>true</createSourcesJar>
- <shadeSourcesContent>true</shadeSourcesContent>
- <artifactSet>
- <includes>
- <include>org.apache.sling:org.apache.sling.scripting.core</include>
- </includes>
- </artifactSet>
- <relocations>
- <relocation>
- <pattern>org.apache.sling.scripting.core.impl.helper</pattern>
- <shadedPattern>slingmodelsimpl.org.apache.sling.scripting.core.impl.helper</shadedPattern>
- </relocation>
- </relocations>
- <filters>
- <filter>
- <artifact>org.apache.sling:org.apache.sling.scripting.core</artifact>
- <includes>
- <include>org/apache/sling/scripting/core/impl/helper/ProtectedBindings*</include>
- </includes>
- </filter>
- </filters>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>dependency-reduced-pom.xml</exclude>
- </excludes>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <configuration>
- <attach>false</attach>
- </configuration>
- </plugin>
- </plugins>
- </build>
<dependencies>
<dependency>
@@ -260,4 +205,107 @@
<scope>provided</scope>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <createSourcesJar>true</createSourcesJar>
+ <shadeSourcesContent>true</shadeSourcesContent>
+ <artifactSet>
+ <includes>
+ <include>org.apache.sling:org.apache.sling.scripting.core</include>
+ </includes>
+ </artifactSet>
+ <relocations>
+ <relocation>
+ <pattern>org.apache.sling.scripting.core.impl.helper</pattern>
+ <shadedPattern>slingmodelsimpl.org.apache.sling.scripting.core.impl.helper</shadedPattern>
+ </relocation>
+ </relocations>
+ <filters>
+ <filter>
+ <artifact>org.apache.sling:org.apache.sling.scripting.core</artifact>
+ <includes>
+ <include>org/apache/sling/scripting/core/impl/helper/ProtectedBindings*</include>
+ </includes>
+ </filter>
+ </filters>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>dependency-reduced-pom.xml</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <configuration>
+ <attach>false</attach>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>2.41.1</version>
+ <configuration>
+ <java>
+ <!-- orders of used formatters are important MPOM-376 -->
+ <!-- eg. palantir override importOrder, so should be first -->
+ <palantirJavaFormat>
+ <version>2.39.0</version>
+ </palantirJavaFormat>
+ <removeUnusedImports />
+ <importOrder>
+ <file>config/maven-eclipse-importorder.txt</file>
+ </importOrder>
+ <licenseHeader>
+ <file>config/maven-header-plain.txt</file>
+ </licenseHeader>
+ </java>
+ <pom>
+ <sortPom>
+ <expandEmptyElements>false</expandEmptyElements>
+ <!-- https://issues.apache.org/jira/browse/MRELEASE-1111 -->
+ <spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
+ <nrOfIndentSpace>4</nrOfIndentSpace>
+ <!-- Indentation -->
+ </sortPom>
+ </pom>
+ <upToDateChecking>
+ <enabled>true</enabled>
+ </upToDateChecking>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-shared-resources</artifactId>
+ <version>5</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/src/main/java/org/apache/sling/models/impl/AdapterImplementations.java b/src/main/java/org/apache/sling/models/impl/AdapterImplementations.java
index 8bac535..ef40327 100644
--- a/src/main/java/org/apache/sling/models/impl/AdapterImplementations.java
+++ b/src/main/java/org/apache/sling/models/impl/AdapterImplementations.java
@@ -50,11 +50,10 @@
private static final Logger log = LoggerFactory.getLogger(AdapterImplementations.class);
- private final ConcurrentMap<String,ConcurrentNavigableMap<String,ModelClass<?>>> adapterImplementations
- = new ConcurrentHashMap<>();
+ private final ConcurrentMap<String, ConcurrentNavigableMap<String, ModelClass<?>>> adapterImplementations =
+ new ConcurrentHashMap<>();
- private final ConcurrentMap<String,ModelClass<?>> modelClasses
- = new ConcurrentHashMap<>();
+ private final ConcurrentMap<String, ModelClass<?>> modelClasses = new ConcurrentHashMap<>();
private final ConcurrentMap<String, Class<?>> resourceTypeMappingsForResources = new ConcurrentHashMap<>();
private final ConcurrentMap<String, Class<?>> resourceTypeMappingsForRequests = new ConcurrentHashMap<>();
@@ -62,10 +61,12 @@
private final ConcurrentMap<Bundle, List<String>> resourceTypeRemovalListsForRequests = new ConcurrentHashMap<>();
private volatile ImplementationPicker[] sortedImplementationPickers = new ImplementationPicker[0];
- private volatile StaticInjectAnnotationProcessorFactory[] sortedStaticInjectAnnotationProcessorFactories = new StaticInjectAnnotationProcessorFactory[0];
+ private volatile StaticInjectAnnotationProcessorFactory[] sortedStaticInjectAnnotationProcessorFactories =
+ new StaticInjectAnnotationProcessorFactory[0];
public void setImplementationPickers(Collection<ImplementationPicker> implementationPickers) {
- this.sortedImplementationPickers = implementationPickers.toArray(new ImplementationPicker[implementationPickers.size()]);
+ this.sortedImplementationPickers =
+ implementationPickers.toArray(new ImplementationPicker[implementationPickers.size()]);
}
public ImplementationPicker[] getImplementationPickers() {
@@ -78,7 +79,8 @@
public void setStaticInjectAnnotationProcessorFactories(
Collection<StaticInjectAnnotationProcessorFactory> factories) {
- this.sortedStaticInjectAnnotationProcessorFactories = factories.toArray(new StaticInjectAnnotationProcessorFactory[factories.size()]);
+ this.sortedStaticInjectAnnotationProcessorFactories =
+ factories.toArray(new StaticInjectAnnotationProcessorFactory[factories.size()]);
updateProcessorFactoriesInModelClasses();
}
@@ -88,12 +90,14 @@
private void updateProcessorFactoriesInModelClasses() {
Iterator<ModelClass<?>> items = modelClasses.values().iterator();
updateProcessorFactoriesInModelClasses(items);
- Iterator<ConcurrentNavigableMap<String,ModelClass<?>>> mapItems = adapterImplementations.values().iterator();
+ Iterator<ConcurrentNavigableMap<String, ModelClass<?>>> mapItems =
+ adapterImplementations.values().iterator();
while (mapItems.hasNext()) {
- ConcurrentNavigableMap<String,ModelClass<?>> mapItem = mapItems.next();
+ ConcurrentNavigableMap<String, ModelClass<?>> mapItem = mapItems.next();
updateProcessorFactoriesInModelClasses(mapItem.values().iterator());
}
}
+
private void updateProcessorFactoriesInModelClasses(Iterator<ModelClass<?>> items) {
while (items.hasNext()) {
ModelClass<?> item = items.next();
@@ -135,11 +139,13 @@
if (adapterType == implType) {
modelClasses.put(key, modelClass);
} else {
- // although we already use a ConcurrentMap synchronize explicitly because we apply non-atomic operations on it
+ // although we already use a ConcurrentMap synchronize explicitly because we apply non-atomic operations
+ // on it
synchronized (adapterImplementations) {
ConcurrentNavigableMap<String, ModelClass<?>> implementations = adapterImplementations.get(key);
if (implementations == null) {
- // to have a consistent ordering independent of bundle loading use a ConcurrentSkipListMap that sorts by class name
+ // to have a consistent ordering independent of bundle loading use a ConcurrentSkipListMap that
+ // sorts by class name
implementations = new ConcurrentSkipListMap<>();
adapterImplementations.put(key, implementations);
}
@@ -159,11 +165,11 @@
String key = adapterTypeName;
if (StringUtils.equals(adapterTypeName, implTypeName)) {
modelClasses.remove(key);
- }
- else {
- // although we already use a ConcurrentMap synchronize explicitly because we apply non-atomic operations on it
+ } else {
+ // although we already use a ConcurrentMap synchronize explicitly because we apply non-atomic operations on
+ // it
synchronized (adapterImplementations) {
- ConcurrentNavigableMap<String,ModelClass<?>> implementations = adapterImplementations.get(key);
+ ConcurrentNavigableMap<String, ModelClass<?>> implementations = adapterImplementations.get(key);
if (implementations != null) {
implementations.remove(implTypeName);
if (implementations.isEmpty()) {
@@ -193,31 +199,32 @@
String key = adapterType.getName();
// lookup in cache for models without adapter classes
- ModelClass<ModelType> modelClass = (ModelClass<ModelType>)modelClasses.get(key);
- if (modelClass!=null) {
+ ModelClass<ModelType> modelClass = (ModelClass<ModelType>) modelClasses.get(key);
+ if (modelClass != null) {
return modelClass;
}
// not found? look in cache with adapter classes
- ConcurrentNavigableMap<String,ModelClass<?>> implementations = adapterImplementations.get(key);
- if (implementations==null || implementations.isEmpty()) {
+ ConcurrentNavigableMap<String, ModelClass<?>> implementations = adapterImplementations.get(key);
+ if (implementations == null || implementations.isEmpty()) {
return null;
}
Collection<ModelClass<?>> implementationsCollection = implementations.values();
- ModelClass<?>[] implementationWrappersArray = implementationsCollection.toArray(new ModelClass<?>[implementationsCollection.size()]);
+ ModelClass<?>[] implementationWrappersArray =
+ implementationsCollection.toArray(new ModelClass<?>[implementationsCollection.size()]);
// prepare array for implementation picker
Class<?>[] implementationsArray = new Class<?>[implementationsCollection.size()];
- for (int i=0; i<implementationWrappersArray.length; i++) {
+ for (int i = 0; i < implementationWrappersArray.length; i++) {
implementationsArray[i] = implementationWrappersArray[i].getType();
}
for (ImplementationPicker picker : this.sortedImplementationPickers) {
Class<?> implementation = picker.pick(adapterType, implementationsArray, adaptable);
if (implementation != null) {
- for (int i=0; i<implementationWrappersArray.length; i++) {
- if (implementation==implementationWrappersArray[i].getType()) {
- return (ModelClass<ModelType>)implementationWrappersArray[i];
+ for (int i = 0; i < implementationWrappersArray.length; i++) {
+ if (implementation == implementationWrappersArray[i].getType()) {
+ return (ModelClass<ModelType>) implementationWrappersArray[i];
}
}
}
@@ -235,65 +242,69 @@
String key = adapterType.getName();
// lookup in cache for models without adapter classes
- ModelClass<ModelType> modelClass = (ModelClass<ModelType>)modelClasses.get(key);
- if (modelClass!=null) {
+ ModelClass<ModelType> modelClass = (ModelClass<ModelType>) modelClasses.get(key);
+ if (modelClass != null) {
return true;
}
// not found? look in cache with adapter classes
- ConcurrentNavigableMap<String,ModelClass<?>> implementations = adapterImplementations.get(key);
- if (implementations==null || implementations.isEmpty()) {
+ ConcurrentNavigableMap<String, ModelClass<?>> implementations = adapterImplementations.get(key);
+ if (implementations == null || implementations.isEmpty()) {
return false;
}
return true;
}
- public void registerModelToResourceType(final Bundle bundle, final String resourceType, final Class<?> adaptableType, final Class<?> clazz) {
- if (resourceType.startsWith("/")) {
- log.warn("Registering model class {} for adaptable {} with absolute resourceType {}." ,
- new Object[] { clazz, adaptableType, resourceType });
- }
- ConcurrentMap<String, Class<?>> map;
- ConcurrentMap<Bundle, List<String>> resourceTypeRemovalLists;
- if (adaptableType == Resource.class) {
- map = resourceTypeMappingsForResources;
- resourceTypeRemovalLists = resourceTypeRemovalListsForResources;
- } else if (adaptableType == SlingHttpServletRequest.class) {
- map = resourceTypeMappingsForRequests;
- resourceTypeRemovalLists = resourceTypeRemovalListsForRequests;
- } else {
- log.warn("Found model class {} with resource type {} for adaptable {}. Unsupported type for resourceType binding.",
- new Object[] { clazz, resourceType, adaptableType });
- return;
- }
- Class<?> existingMapping = map.putIfAbsent(resourceType, clazz);
- if (existingMapping == null) {
- resourceTypeRemovalLists.putIfAbsent(bundle, new CopyOnWriteArrayList<String>());
- resourceTypeRemovalLists.get(bundle).add(resourceType);
- } else {
- log.warn("Skipped registering {} for resourceType {} under adaptable {} because of existing mapping to {}",
- new Object[] { clazz, resourceType, adaptableType, existingMapping });
- }
- }
+ public void registerModelToResourceType(
+ final Bundle bundle, final String resourceType, final Class<?> adaptableType, final Class<?> clazz) {
+ if (resourceType.startsWith("/")) {
+ log.warn(
+ "Registering model class {} for adaptable {} with absolute resourceType {}.",
+ new Object[] {clazz, adaptableType, resourceType});
+ }
+ ConcurrentMap<String, Class<?>> map;
+ ConcurrentMap<Bundle, List<String>> resourceTypeRemovalLists;
+ if (adaptableType == Resource.class) {
+ map = resourceTypeMappingsForResources;
+ resourceTypeRemovalLists = resourceTypeRemovalListsForResources;
+ } else if (adaptableType == SlingHttpServletRequest.class) {
+ map = resourceTypeMappingsForRequests;
+ resourceTypeRemovalLists = resourceTypeRemovalListsForRequests;
+ } else {
+ log.warn(
+ "Found model class {} with resource type {} for adaptable {}. Unsupported type for resourceType binding.",
+ new Object[] {clazz, resourceType, adaptableType});
+ return;
+ }
+ Class<?> existingMapping = map.putIfAbsent(resourceType, clazz);
+ if (existingMapping == null) {
+ resourceTypeRemovalLists.putIfAbsent(bundle, new CopyOnWriteArrayList<String>());
+ resourceTypeRemovalLists.get(bundle).add(resourceType);
+ } else {
+ log.warn(
+ "Skipped registering {} for resourceType {} under adaptable {} because of existing mapping to {}",
+ new Object[] {clazz, resourceType, adaptableType, existingMapping});
+ }
+ }
- public void removeResourceTypeBindings(final Bundle bundle) {
- List<String> registeredResourceTypes = resourceTypeRemovalListsForResources.remove(bundle);
- if (registeredResourceTypes != null) {
- for (String resourceType : registeredResourceTypes) {
- resourceTypeMappingsForResources.remove(resourceType);
- }
- }
- registeredResourceTypes = resourceTypeRemovalListsForRequests.remove(bundle);
- if (registeredResourceTypes != null) {
- for (String resourceType : registeredResourceTypes) {
- resourceTypeMappingsForRequests.remove(resourceType);
- }
- }
- }
+ public void removeResourceTypeBindings(final Bundle bundle) {
+ List<String> registeredResourceTypes = resourceTypeRemovalListsForResources.remove(bundle);
+ if (registeredResourceTypes != null) {
+ for (String resourceType : registeredResourceTypes) {
+ resourceTypeMappingsForResources.remove(resourceType);
+ }
+ }
+ registeredResourceTypes = resourceTypeRemovalListsForRequests.remove(bundle);
+ if (registeredResourceTypes != null) {
+ for (String resourceType : registeredResourceTypes) {
+ resourceTypeMappingsForRequests.remove(resourceType);
+ }
+ }
+ }
- public Class<?> getModelClassForRequest(final SlingHttpServletRequest request) {
- return getModelClassForResource(request.getResource(), resourceTypeMappingsForRequests);
- }
+ public Class<?> getModelClassForRequest(final SlingHttpServletRequest request) {
+ return getModelClassForResource(request.getResource(), resourceTypeMappingsForRequests);
+ }
public Class<?> getModelClassForResource(final Resource resource) {
return getModelClassForResource(resource, resourceTypeMappingsForResources);
@@ -327,7 +338,8 @@
}
}
- private static Class<?> getClassFromResourceTypeMap(final String resourceType, final Map<String, Class<?>> map, final ResourceResolver resolver) {
+ private static Class<?> getClassFromResourceTypeMap(
+ final String resourceType, final Map<String, Class<?>> map, final ResourceResolver resolver) {
if (resourceType == null) {
return null;
}
diff --git a/src/main/java/org/apache/sling/models/impl/ExportServlet.java b/src/main/java/org/apache/sling/models/impl/ExportServlet.java
index 736ba10..cdb318d 100644
--- a/src/main/java/org/apache/sling/models/impl/ExportServlet.java
+++ b/src/main/java/org/apache/sling/models/impl/ExportServlet.java
@@ -18,13 +18,9 @@
*/
package org.apache.sling.models.impl;
-import static org.apache.sling.api.scripting.SlingBindings.LOG;
-import static org.apache.sling.api.scripting.SlingBindings.OUT;
-import static org.apache.sling.api.scripting.SlingBindings.READER;
-import static org.apache.sling.api.scripting.SlingBindings.REQUEST;
-import static org.apache.sling.api.scripting.SlingBindings.RESOURCE;
-import static org.apache.sling.api.scripting.SlingBindings.RESPONSE;
-import static org.apache.sling.api.scripting.SlingBindings.SLING;
+import javax.script.Bindings;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
@@ -32,10 +28,6 @@
import java.util.HashMap;
import java.util.Map;
-import javax.script.Bindings;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.scripting.LazyBindings;
@@ -51,6 +43,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.apache.sling.api.scripting.SlingBindings.LOG;
+import static org.apache.sling.api.scripting.SlingBindings.OUT;
+import static org.apache.sling.api.scripting.SlingBindings.READER;
+import static org.apache.sling.api.scripting.SlingBindings.REQUEST;
+import static org.apache.sling.api.scripting.SlingBindings.RESOURCE;
+import static org.apache.sling.api.scripting.SlingBindings.RESPONSE;
+import static org.apache.sling.api.scripting.SlingBindings.SLING;
+
@SuppressWarnings("serial")
class ExportServlet extends SlingSafeMethodsServlet {
@@ -68,10 +68,16 @@
private final ExportedObjectAccessor accessor;
private final Map<String, String> baseOptions;
- public ExportServlet(BundleContext bundleContext, ModelFactory modelFactory,
- BindingsValuesProvidersByContext bindingsValuesProvidersByContext, SlingModelsScriptEngineFactory scriptFactory,
- Class<?> annotatedClass, String registeredSelector, String exporterName, ExportedObjectAccessor accessor,
- Map<String, String> baseOptions) {
+ public ExportServlet(
+ BundleContext bundleContext,
+ ModelFactory modelFactory,
+ BindingsValuesProvidersByContext bindingsValuesProvidersByContext,
+ SlingModelsScriptEngineFactory scriptFactory,
+ Class<?> annotatedClass,
+ String registeredSelector,
+ String exporterName,
+ ExportedObjectAccessor accessor,
+ Map<String, String> baseOptions) {
this.bundleContext = bundleContext;
this.modelFactory = modelFactory;
this.bindingsValuesProvidersByContext = bindingsValuesProvidersByContext;
@@ -124,12 +130,14 @@
}
}
- private void addScriptBindings(SlingScriptHelper scriptHelper, SlingHttpServletRequest request, SlingHttpServletResponse response)
+ private void addScriptBindings(
+ SlingScriptHelper scriptHelper, SlingHttpServletRequest request, SlingHttpServletResponse response)
throws IOException {
Bindings bindings = new LazyBindings();
bindings.put(SLING, scriptHelper);
bindings.put(RESOURCE, request.getResource());
- bindings.put(SlingModelsScriptEngineFactory.RESOLVER, request.getResource().getResourceResolver());
+ bindings.put(
+ SlingModelsScriptEngineFactory.RESOLVER, request.getResource().getResourceResolver());
bindings.put(REQUEST, request);
bindings.put(RESPONSE, response);
try {
@@ -146,13 +154,13 @@
slingBindings.putAll(bindings);
request.setAttribute(SlingBindings.class.getName(), slingBindings);
-
}
private Map<String, String> createOptionMap(SlingHttpServletRequest request) {
Map<String, String[]> parameterMap = request.getParameterMap();
String[] selectors = request.getRequestPathInfo().getSelectors();
- Map<String, String> result = new HashMap<String, String>(baseOptions.size() + parameterMap.size() + selectors.length - 1);
+ Map<String, String> result =
+ new HashMap<String, String>(baseOptions.size() + parameterMap.size() + selectors.length - 1);
result.putAll(baseOptions);
for (String selector : selectors) {
if (!selector.equals(registeredSelector)) {
@@ -171,7 +179,12 @@
}
public interface ExportedObjectAccessor {
- String getExportedString(SlingHttpServletRequest request, Map<String, String> options, ModelFactory modelFactory, String exporterName) throws ExportException, MissingExporterException;
+ String getExportedString(
+ SlingHttpServletRequest request,
+ Map<String, String> options,
+ ModelFactory modelFactory,
+ String exporterName)
+ throws ExportException, MissingExporterException;
}
public static final class ResourceAccessor implements ExportedObjectAccessor {
@@ -183,7 +196,12 @@
}
@Override
- public String getExportedString(SlingHttpServletRequest request, Map<String, String> options, ModelFactory modelFactory, String exporterName) throws ExportException, MissingExporterException {
+ public String getExportedString(
+ SlingHttpServletRequest request,
+ Map<String, String> options,
+ ModelFactory modelFactory,
+ String exporterName)
+ throws ExportException, MissingExporterException {
Object adapter = modelFactory.createModel(request.getResource(), adapterClass);
return modelFactory.exportModel(adapter, exporterName, String.class, options);
}
@@ -198,10 +216,15 @@
}
@Override
- public String getExportedString(SlingHttpServletRequest request, Map<String, String> options, ModelFactory modelFactory, String exporterName) throws ExportException, MissingExporterException {
+ public String getExportedString(
+ SlingHttpServletRequest request,
+ Map<String, String> options,
+ ModelFactory modelFactory,
+ String exporterName)
+ throws ExportException, MissingExporterException {
Object adapter = modelFactory.createModel(request, adapterClass);
return modelFactory.exportModel(adapter, exporterName, String.class, options);
}
- };
-
+ }
+ ;
}
diff --git a/src/main/java/org/apache/sling/models/impl/FirstImplementationPicker.java b/src/main/java/org/apache/sling/models/impl/FirstImplementationPicker.java
index 89b6c96..aba322b 100644
--- a/src/main/java/org/apache/sling/models/impl/FirstImplementationPicker.java
+++ b/src/main/java/org/apache/sling/models/impl/FirstImplementationPicker.java
@@ -30,13 +30,13 @@
* But at least it gives a consistent behavior.
* It's service ranking is set to the highest value to allow more intelligent implementations to step in.
*/
-@Component(property=Constants.SERVICE_RANKING+":Integer="+Integer.MAX_VALUE, service=ImplementationPicker.class)
+@Component(property = Constants.SERVICE_RANKING + ":Integer=" + Integer.MAX_VALUE, service = ImplementationPicker.class)
public class FirstImplementationPicker implements ImplementationPicker {
@Override
- public Class<?> pick(@NotNull Class<?> adapterType, Class<?> @NotNull [] implementationsTypes, @NotNull Object adaptable) {
+ public Class<?> pick(
+ @NotNull Class<?> adapterType, Class<?> @NotNull [] implementationsTypes, @NotNull Object adaptable) {
// implementations is never null or empty
return implementationsTypes[0];
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/models/impl/MapBackedInvocationHandler.java b/src/main/java/org/apache/sling/models/impl/MapBackedInvocationHandler.java
index c486781..4109c1c 100644
--- a/src/main/java/org/apache/sling/models/impl/MapBackedInvocationHandler.java
+++ b/src/main/java/org/apache/sling/models/impl/MapBackedInvocationHandler.java
@@ -33,5 +33,4 @@
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return methods.get(method);
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java b/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
index 9724013..2aa6ffb 100644
--- a/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
+++ b/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
@@ -1,21 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
+import javax.annotation.PostConstruct;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.ServletRequestWrapper;
+
import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
@@ -24,12 +32,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import javax.annotation.PostConstruct;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletRequestEvent;
-import javax.servlet.ServletRequestListener;
-import javax.servlet.ServletRequestWrapper;
-
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.adapter.Adaptable;
@@ -93,10 +95,15 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Component(immediate = true, service={ ModelFactory.class, ServletRequestListener.class },
- property= { HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER+"=true",
- HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT+"=(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=*)" })
-@Designate(ocd=ModelAdapterFactoryConfiguration.class)
+@Component(
+ immediate = true,
+ service = {ModelFactory.class, ServletRequestListener.class},
+ property = {
+ HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER + "=true",
+ HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT + "=("
+ + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=*)"
+ })
+@Designate(ocd = ModelAdapterFactoryConfiguration.class)
@SuppressWarnings("deprecation")
public class ModelAdapterFactory implements AdapterFactory, Runnable, ModelFactory, ServletRequestListener {
@@ -122,14 +129,12 @@
callbacks = Collections.unmodifiableList(callbacks);
}
-
@Override
public void onDisposed() {
for (DisposalCallback callback : callbacks) {
callback.onDisposed();
}
}
-
}
private static class CombinedDisposable implements Disposable {
@@ -147,7 +152,7 @@
}
}
- private interface Disposable {
+ private interface Disposable {
void onDisposed();
}
@@ -208,18 +213,27 @@
private final RankedServices<Injector> sortedInjectors = new RankedServices<>();
private final ConcurrentMap<Class<? extends ViaProviderType>, ViaProvider> viaProviders = new ConcurrentHashMap<>();
- @Reference(name="injectAnnotationProcessorFactory", cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
- volatile Collection<InjectAnnotationProcessorFactory> injectAnnotationProcessorFactories; // this must be non-final for fieldOption=replace!
+ @Reference(
+ name = "injectAnnotationProcessorFactory",
+ cardinality = ReferenceCardinality.MULTIPLE,
+ policy = ReferencePolicy.DYNAMIC)
+ volatile Collection<InjectAnnotationProcessorFactory>
+ injectAnnotationProcessorFactories; // this must be non-final for fieldOption=replace!
- @Reference(name="injectAnnotationProcessorFactory2", cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
- volatile Collection<InjectAnnotationProcessorFactory2> injectAnnotationProcessorFactories2; // this must be non-final for fieldOption=replace!
+ @Reference(
+ name = "injectAnnotationProcessorFactory2",
+ cardinality = ReferenceCardinality.MULTIPLE,
+ policy = ReferencePolicy.DYNAMIC)
+ volatile Collection<InjectAnnotationProcessorFactory2>
+ injectAnnotationProcessorFactories2; // this must be non-final for fieldOption=replace!
- private final RankedServices<StaticInjectAnnotationProcessorFactory> staticInjectAnnotationProcessorFactories = new RankedServices<>();
+ private final RankedServices<StaticInjectAnnotationProcessorFactory> staticInjectAnnotationProcessorFactories =
+ new RankedServices<>();
private final RankedServices<ImplementationPicker> implementationPickers = new RankedServices<>();
// bind the service with the highest priority (if a new one comes in this service gets restarted)
- @Reference(cardinality=ReferenceCardinality.OPTIONAL, policyOption=ReferencePolicyOption.GREEDY)
+ @Reference(cardinality = ReferenceCardinality.OPTIONAL, policyOption = ReferencePolicyOption.GREEDY)
private ModelValidation modelValidation = null;
@Reference(name = "modelExporter", cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
@@ -239,7 +253,8 @@
private ServiceRegistration configPrinterRegistration;
- // Use threadlocal to count recursive invocations and break recursing if a max. limit is reached (to avoid cyclic dependencies)
+ // Use threadlocal to count recursive invocations and break recursing if a max. limit is reached (to avoid cyclic
+ // dependencies)
private ThreadLocal<ThreadInvocationCounter> invocationCountThreadLocal;
private Map<Object, Map<Class<?>, SoftReference<Object>>> adapterCache;
@@ -252,7 +267,8 @@
Result<AdapterType> result = internalCreateModel(adaptable, type);
if (!result.wasSuccessful()) {
if (result == Result.POST_CONSTRUCT_PREVENTED_MODEL_CONSTRUCTION) {
- log.debug("Could not adapt to model as PostConstruct method returned false"); // do no construct runtime exception in this case
+ log.debug("Could not adapt to model as PostConstruct method returned false"); // do no construct runtime
+ // exception in this case
} else {
log.warn("Could not adapt to model", result.getThrowable());
}
@@ -263,8 +279,8 @@
}
@Override
- public @NotNull <ModelType> ModelType createModel(@NotNull Object adaptable, @NotNull Class<ModelType> type) throws MissingElementsException,
- InvalidAdaptableException, ValidationException, InvalidModelException {
+ public @NotNull <ModelType> ModelType createModel(@NotNull Object adaptable, @NotNull Class<ModelType> type)
+ throws MissingElementsException, InvalidAdaptableException, ValidationException, InvalidModelException {
Result<ModelType> result = internalCreateModel(adaptable, type);
if (!result.wasSuccessful()) {
throw result.getThrowable();
@@ -273,16 +289,22 @@
}
@Override
- public @NotNull<T> T createModelFromWrappedRequest(@NotNull SlingHttpServletRequest request, @NotNull Resource resource, @NotNull Class<T> targetClass) {
- return createModel(new ResourceOverridingRequestWrapper(request, resource, adapterManager, scriptEngineFactory, bindingsValuesProvidersByContext), targetClass);
+ public @NotNull <T> T createModelFromWrappedRequest(
+ @NotNull SlingHttpServletRequest request, @NotNull Resource resource, @NotNull Class<T> targetClass) {
+ return createModel(
+ new ResourceOverridingRequestWrapper(
+ request, resource, adapterManager, scriptEngineFactory, bindingsValuesProvidersByContext),
+ targetClass);
}
-
+
@Override
- public boolean canCreateFromAdaptable(@NotNull Object adaptable, @NotNull Class<?> modelClass) throws ModelClassException {
+ public boolean canCreateFromAdaptable(@NotNull Object adaptable, @NotNull Class<?> modelClass)
+ throws ModelClassException {
return internalCanCreateFromAdaptable(adaptable, modelClass);
}
- private boolean internalCanCreateFromAdaptable(Object adaptable, Class<?> requestedType) throws ModelClassException {
+ private boolean internalCanCreateFromAdaptable(Object adaptable, Class<?> requestedType)
+ throws ModelClassException {
try {
ModelClass<?> modelClass = getImplementationTypeForAdapterType(requestedType, adaptable);
Class<?>[] declaredAdaptable = modelClass.getModelAnnotation().adaptables();
@@ -292,7 +314,10 @@
}
}
} catch (ModelClassException e) {
- log.debug("Could not find implementation for given type " + requestedType + ". Probably forgot either the model annotation or it was not registered as adapter factory (yet)", e);
+ log.debug(
+ "Could not find implementation for given type " + requestedType
+ + ". Probably forgot either the model annotation or it was not registered as adapter factory (yet)",
+ e);
return false;
}
return false;
@@ -304,7 +329,9 @@
try {
getImplementationTypeForAdapterType(requestedType, adaptable);
} catch (ModelClassException e) {
- log.debug("Could not find implementation for given adaptable. Probably forgot either the model annotation or it was not registered as adapter factory (yet)", e);
+ log.debug(
+ "Could not find implementation for given adaptable. Probably forgot either the model annotation or it was not registered as adapter factory (yet)",
+ e);
return false;
}
return true;
@@ -324,7 +351,8 @@
* href="http://sling.apache.org/documentation/bundles/models.html#specifying-an-alternate-adapter-class-since-sling-models-110">Specifying
* an Alternate Adapter Class</a>
*/
- private <ModelType> ModelClass<ModelType> getImplementationTypeForAdapterType(Class<ModelType> requestedType, Object adaptable) {
+ private <ModelType> ModelClass<ModelType> getImplementationTypeForAdapterType(
+ Class<ModelType> requestedType, Object adaptable) {
// lookup ModelClass wrapper for implementation type
// additionally check if a different implementation class was registered for this adapter type
// the adapter implementation is initially filled by the ModelPackageBundleList
@@ -334,7 +362,8 @@
return modelClass;
}
// throw exception here
- throw new ModelClassException("Could not yet find an adapter factory for the model " + requestedType + " from adaptable " + adaptable.getClass());
+ throw new ModelClassException("Could not yet find an adapter factory for the model " + requestedType
+ + " from adaptable " + adaptable.getClass());
}
@SuppressWarnings("unchecked")
@@ -348,7 +377,8 @@
request.setAttribute(REQUEST_CACHE_ATTRIBUTE, adaptableCache);
}
} else {
- adaptableCache = adapterCache.computeIfAbsent(adaptable, k -> Collections.synchronizedMap(new WeakHashMap<>()));
+ adaptableCache =
+ adapterCache.computeIfAbsent(adaptable, k -> Collections.synchronizedMap(new WeakHashMap<>()));
}
return adaptableCache;
}
@@ -358,7 +388,8 @@
Result<ModelType> result;
ThreadInvocationCounter threadInvocationCounter = invocationCountThreadLocal.get();
if (threadInvocationCounter.isMaximumReached()) {
- String msg = String.format("Adapting %s to %s failed, too much recursive invocations (>=%s).",
+ String msg = String.format(
+ "Adapting %s to %s failed, too much recursive invocations (>=%s).",
adaptable, requestedType, threadInvocationCounter.maxRecursionDepth);
return new Result<>(new ModelClassException(msg));
}
@@ -368,7 +399,8 @@
ModelClass<ModelType> modelClass = getImplementationTypeForAdapterType(requestedType, adaptable);
if (!modelClass.hasModelAnnotation()) {
- String msg = String.format("Provided Adapter class does not have a Model annotation: %s", modelClass.getType());
+ String msg = String.format(
+ "Provided Adapter class does not have a Model annotation: %s", modelClass.getType());
return new Result<>(new ModelClassException(msg));
}
boolean isAdaptable = false;
@@ -394,7 +426,9 @@
}
}
if (!isAdaptable) {
- String msg = String.format("Given adaptable (%s) is not acceptable for the model class: %s which only supports adaptables %s", adaptable.getClass(), modelClass.getType(), StringUtils.join(declaredAdaptable));
+ String msg = String.format(
+ "Given adaptable (%s) is not acceptable for the model class: %s which only supports adaptables %s",
+ adaptable.getClass(), modelClass.getType(), StringUtils.join(declaredAdaptable));
return new Result<>(new InvalidAdaptableException(msg));
} else {
RuntimeException t = validateModel(adaptable, modelClass.getType(), modelAnnotation);
@@ -404,7 +438,10 @@
if (modelClass.getType().isInterface()) {
Result<InvocationHandler> handlerResult = createInvocationHandler(adaptable, modelClass);
if (handlerResult.wasSuccessful()) {
- ModelType model = (ModelType) Proxy.newProxyInstance(modelClass.getType().getClassLoader(), new Class<?>[] { modelClass.getType() }, handlerResult.getValue());
+ ModelType model = (ModelType) Proxy.newProxyInstance(
+ modelClass.getType().getClassLoader(),
+ new Class<?>[] {modelClass.getType()},
+ handlerResult.getValue());
if (modelAnnotation.cache() && adaptableCache != null) {
adaptableCache.put(modelClass.getType(), new SoftReference<>(model));
@@ -433,12 +470,15 @@
}
}
- private <ModelType> RuntimeException validateModel(Object adaptable, Class<ModelType> modelType, Model modelAnnotation) {
+ private <ModelType> RuntimeException validateModel(
+ Object adaptable, Class<ModelType> modelType, Model modelAnnotation) {
if (modelAnnotation.validation() != ValidationStrategy.DISABLED) {
if (modelValidation == null) {
- return new ValidationException("No active service for ModelValidation found, therefore no validation can be performed.");
+ return new ValidationException(
+ "No active service for ModelValidation found, therefore no validation can be performed.");
}
- return modelValidation.validate(adaptable, modelType, modelAnnotation.validation() == ValidationStrategy.REQUIRED);
+ return modelValidation.validate(
+ adaptable, modelType, modelAnnotation.validation() == ValidationStrategy.REQUIRED);
}
return null;
}
@@ -471,7 +511,7 @@
private final Map<Method, Object> methods;
- private SetMethodsCallback( Map<Method, Object> methods) {
+ private SetMethodsCallback(Map<Method, Object> methods) {
this.methods = methods;
}
@@ -491,7 +531,7 @@
@Override
public RuntimeException inject(InjectableElement element, Object value) {
- return setConstructorParameter((ConstructorParameter)element, parameterValues, value);
+ return setConstructorParameter((ConstructorParameter) element, parameterValues, value);
}
}
@@ -507,18 +547,21 @@
@Override
public RuntimeException inject(InjectableElement element1, Object value) {
- return chainedCallback.inject(element, value.equals(Optional.empty())
- ? value // if the value is null it's already represented as Optional.empty(), return as is
- : Optional.of(value)); // otherwise wrap in Optional
+ return chainedCallback.inject(
+ element,
+ value.equals(Optional.empty())
+ ? value // if the value is null it's already represented as Optional.empty(), return as is
+ : Optional.of(value)); // otherwise wrap in Optional
}
}
- private
- @Nullable
- RuntimeException injectElement(final InjectableElement element, final Object adaptable,
- final @NotNull DisposalCallbackRegistry registry, final InjectCallback callback,
- final @NotNull Map<ValuePreparer, Object> preparedValues,
- final @Nullable BundleContext modelContext) {
+ private @Nullable RuntimeException injectElement(
+ final InjectableElement element,
+ final Object adaptable,
+ final @NotNull DisposalCallbackRegistry registry,
+ final InjectCallback callback,
+ final @NotNull Map<ValuePreparer, Object> preparedValues,
+ final @Nullable BundleContext modelContext) {
if (element instanceof InjectableField) {
Type genericType = ((InjectableField) element).getFieldGenericType();
@@ -526,10 +569,12 @@
ParameterizedType pType = (ParameterizedType) genericType;
if (pType.getRawType().equals(Optional.class)) {
- InjectableElement el = new OptionalTypedInjectableElement(element, pType.getActualTypeArguments()[0]);
+ InjectableElement el =
+ new OptionalTypedInjectableElement(element, pType.getActualTypeArguments()[0]);
InjectCallback wrappedCallback = new OptionalWrappingCallback(callback, element);
- return injectElementInternal(el, adaptable, registry, wrappedCallback, preparedValues, modelContext);
+ return injectElementInternal(
+ el, adaptable, registry, wrappedCallback, preparedValues, modelContext);
}
}
}
@@ -537,12 +582,13 @@
return injectElementInternal(element, adaptable, registry, callback, preparedValues, modelContext);
}
- private
- @Nullable
- RuntimeException injectElementInternal(final InjectableElement element, final Object adaptable,
- final @NotNull DisposalCallbackRegistry registry, final InjectCallback callback,
- final @NotNull Map<ValuePreparer, Object> preparedValues,
- final @Nullable BundleContext modelContext) {
+ private @Nullable RuntimeException injectElementInternal(
+ final InjectableElement element,
+ final Object adaptable,
+ final @NotNull DisposalCallbackRegistry registry,
+ final InjectCallback callback,
+ final @NotNull Map<ValuePreparer, Object> preparedValues,
+ final @Nullable BundleContext modelContext) {
InjectAnnotationProcessor annotationProcessor = null;
String source = element.getSource();
@@ -574,11 +620,11 @@
final RankedServices<Injector> injectorsToProcess;
if (StringUtils.isEmpty(source)) {
injectorsToProcess = sortedInjectors;
- }
- else {
+ } else {
injectorsToProcess = injectors.get(source);
if (injectorsToProcess == null) {
- throw new IllegalArgumentException("No Sling Models Injector registered for source '" + source + "'.");
+ throw new IllegalArgumentException(
+ "No Sling Models Injector registered for source '" + source + "'.");
}
}
@@ -600,9 +646,17 @@
}
Object value = null;
if (injector instanceof OSGiServiceInjector) {
- value = ((OSGiServiceInjector)injector).getValue(preparedValue, name, element.getType(), element.getAnnotatedElement(), registry, modelContext);
+ value = ((OSGiServiceInjector) injector)
+ .getValue(
+ preparedValue,
+ name,
+ element.getType(),
+ element.getAnnotatedElement(),
+ registry,
+ modelContext);
} else {
- value = injector.getValue(preparedValue, name, element.getType(), element.getAnnotatedElement(), registry);
+ value = injector.getValue(
+ preparedValue, name, element.getType(), element.getAnnotatedElement(), registry);
}
if (value != null) {
lastInjectionException = callback.inject(element, value);
@@ -621,7 +675,11 @@
wasInjectionSuccessful = defaultInjectionResult.getValue();
// log previous injection error, if there was any
if (lastInjectionException != null && wasInjectionSuccessful) {
- log.debug("Although falling back to default value worked, injection into {} failed because of: " + lastInjectionException.getMessage(), element.getAnnotatedElement(), lastInjectionException);
+ log.debug(
+ "Although falling back to default value worked, injection into {} failed because of: "
+ + lastInjectionException.getMessage(),
+ element.getAnnotatedElement(),
+ lastInjectionException);
}
} else {
return defaultInjectionResult.getThrowable();
@@ -633,7 +691,11 @@
if (element.isOptional(annotationProcessor)) {
// log previous injection error, if there was any
if (lastInjectionException != null) {
- log.debug("Injection into optional element {} failed because of: " + lastInjectionException.getMessage(), element.getAnnotatedElement(), lastInjectionException);
+ log.debug(
+ "Injection into optional element {} failed because of: "
+ + lastInjectionException.getMessage(),
+ element.getAnnotatedElement(),
+ lastInjectionException);
}
if (element.isPrimitive()) {
RuntimeException throwable = injectPrimitiveInitialValue(element, callback);
@@ -660,7 +722,8 @@
return null;
}
- private <ModelType> Result<InvocationHandler> createInvocationHandler(final Object adaptable, final ModelClass<ModelType> modelClass) {
+ private <ModelType> Result<InvocationHandler> createInvocationHandler(
+ final Object adaptable, final ModelClass<ModelType> modelClass) {
InjectableMethod[] injectableMethods = modelClass.getInjectableMethods();
final Map<Method, Object> methods = new HashMap<>();
SetMethodsCallback callback = new SetMethodsCallback(methods);
@@ -684,15 +747,17 @@
if (!registry.callbacks.isEmpty()) {
registry.seal();
- if (adaptable instanceof SlingHttpServletRequest &&
- ((SlingHttpServletRequest) adaptable).getAttribute(REQUEST_MARKER_ATTRIBUTE) == REQUEST_MARKER_VALUE) {
+ if (adaptable instanceof SlingHttpServletRequest
+ && ((SlingHttpServletRequest) adaptable).getAttribute(REQUEST_MARKER_ATTRIBUTE)
+ == REQUEST_MARKER_VALUE) {
registerRequestCallbackRegistry((SlingHttpServletRequest) adaptable, registry);
} else {
registerCallbackRegistry(handler, registry);
}
}
if (missingElements != null) {
- MissingElementsException missingElementsException = new MissingElementsException("Could not create all mandatory methods for interface of model " + modelClass);
+ MissingElementsException missingElementsException = new MissingElementsException(
+ "Could not create all mandatory methods for interface of model " + modelClass);
for (MissingElementException me : missingElements) {
missingElementsException.addMissingElementExceptions(me);
}
@@ -725,7 +790,8 @@
ModelClassConstructor<ModelType> constructorToUse = getBestMatchingConstructor(adaptable, modelClass);
if (constructorToUse == null) {
- return new Result<>(new ModelClassException("Unable to find a useable constructor for model " + modelClass.getType()));
+ return new Result<>(
+ new ModelClassException("Unable to find a useable constructor for model " + modelClass.getType()));
}
final Map<ValuePreparer, Object> preparedValues = new HashMap<>(VALUE_PREPARERS_COUNT);
@@ -739,7 +805,8 @@
// instantiate with constructor injection
// if this fails, make sure resources that may be claimed by injectors are cleared up again
try {
- Result<ModelType> result = newInstanceWithConstructorInjection(constructorToUse, adaptable, modelClass, registry, preparedValues);
+ Result<ModelType> result = newInstanceWithConstructorInjection(
+ constructorToUse, adaptable, modelClass, registry, preparedValues);
if (!result.wasSuccessful()) {
registry.onDisposed();
return result;
@@ -770,16 +837,17 @@
if (!registry.callbacks.isEmpty()) {
registry.seal();
- if (adaptable instanceof SlingHttpServletRequest &&
- ((SlingHttpServletRequest) adaptable).getAttribute(REQUEST_MARKER_ATTRIBUTE) == REQUEST_MARKER_VALUE) {
+ if (adaptable instanceof SlingHttpServletRequest
+ && ((SlingHttpServletRequest) adaptable).getAttribute(REQUEST_MARKER_ATTRIBUTE)
+ == REQUEST_MARKER_VALUE) {
registerRequestCallbackRegistry((SlingHttpServletRequest) adaptable, registry);
} else {
registerCallbackRegistry(object, registry);
}
-
}
if (missingElements != null) {
- MissingElementsException missingElementsException = new MissingElementsException("Could not inject all required fields into " + modelClass.getType());
+ MissingElementsException missingElementsException =
+ new MissingElementsException("Could not inject all required fields into " + modelClass.getType());
for (MissingElementException me : missingElements) {
missingElementsException.addMissingElementExceptions(me);
}
@@ -791,9 +859,11 @@
return (Result<ModelType>) Result.POST_CONSTRUCT_PREVENTED_MODEL_CONSTRUCTION;
}
} catch (InvocationTargetException e) {
- return new Result<>(new PostConstructException("Post-construct method has thrown an exception for model " + modelClass.getType(), e.getCause()));
+ return new Result<>(new PostConstructException(
+ "Post-construct method has thrown an exception for model " + modelClass.getType(), e.getCause()));
} catch (IllegalAccessException e) {
- new Result<ModelType>(new ModelClassException("Could not call post-construct method for model " + modelClass.getType(), e));
+ new Result<ModelType>(new ModelClassException(
+ "Could not call post-construct method for model " + modelClass.getType(), e));
}
return new Result<>(object);
}
@@ -804,7 +874,8 @@
* @param type Model type
* @return Constructor or null if none found
*/
- private <ModelType> ModelClassConstructor<ModelType> getBestMatchingConstructor(Object adaptable, ModelClass<ModelType> type) {
+ private <ModelType> ModelClassConstructor<ModelType> getBestMatchingConstructor(
+ Object adaptable, ModelClass<ModelType> type) {
ModelClassConstructor<ModelType>[] constructors = type.getConstructors();
for (ModelClassConstructor<ModelType> constructor : constructors) {
@@ -829,8 +900,12 @@
return null;
}
- private <ModelType> Result<ModelType> newInstanceWithConstructorInjection(final ModelClassConstructor<ModelType> constructor, final Object adaptable,
- final ModelClass<ModelType> modelClass, final DisposalCallbackRegistry registry, final @NotNull Map<ValuePreparer, Object> preparedValues)
+ private <ModelType> Result<ModelType> newInstanceWithConstructorInjection(
+ final ModelClassConstructor<ModelType> constructor,
+ final Object adaptable,
+ final ModelClass<ModelType> modelClass,
+ final DisposalCallbackRegistry registry,
+ final @NotNull Map<ValuePreparer, Object> preparedValues)
throws InstantiationException, InvocationTargetException, IllegalAccessException {
ConstructorParameter[] parameters = constructor.getConstructorParameters();
@@ -840,7 +915,8 @@
final BundleContext modelContext = getModelBundleContext(modelClass);
List<MissingElementException> missingElements = null;
for (int i = 0; i < parameters.length; i++) {
- RuntimeException t = injectElement(parameters[i], adaptable, registry, callback, preparedValues, modelContext);
+ RuntimeException t =
+ injectElement(parameters[i], adaptable, registry, callback, preparedValues, modelContext);
if (t != null) {
if (missingElements == null) {
missingElements = new ArrayList<>();
@@ -849,7 +925,8 @@
}
}
if (missingElements != null) {
- MissingElementsException missingElementsException = new MissingElementsException("Required constructor parameters were not able to be injected on model " + modelClass.getType());
+ MissingElementsException missingElementsException = new MissingElementsException(
+ "Required constructor parameters were not able to be injected on model " + modelClass.getType());
for (MissingElementException me : missingElements) {
missingElementsException.addMissingElementExceptions(me);
}
@@ -858,8 +935,8 @@
return new Result<>(constructor.newInstance(paramValues.toArray(new Object[paramValues.size()])));
}
- private Result<Boolean> injectDefaultValue(InjectableElement point, InjectAnnotationProcessor processor,
- InjectCallback callback) {
+ private Result<Boolean> injectDefaultValue(
+ InjectableElement point, InjectAnnotationProcessor processor, InjectCallback callback) {
if (processor != null) {
if (processor.hasDefault()) {
RuntimeException t = callback.inject(point, processor.getDefault());
@@ -879,8 +956,7 @@
} else {
return new Result<>(t);
}
- }
- else {
+ } else {
return new Result<>(Boolean.FALSE);
}
}
@@ -961,7 +1037,7 @@
private boolean addMethodIfNotOverriden(List<Method> methods, Method newMethod) {
for (Method method : methods) {
if (method.getName().equals(newMethod.getName())) {
- if (Arrays.equals(method.getParameterTypes(),newMethod.getParameterTypes())) {
+ if (Arrays.equals(method.getParameterTypes(), newMethod.getParameterTypes())) {
return false;
}
}
@@ -971,7 +1047,8 @@
}
@SuppressWarnings("null")
- private <ModelType> ModelType invokePostConstruct(ModelType object) throws InvocationTargetException, IllegalAccessException {
+ private <ModelType> ModelType invokePostConstruct(ModelType object)
+ throws InvocationTargetException, IllegalAccessException {
Class<?> clazz = object.getClass();
List<Method> postConstructMethods = new ArrayList<>();
while (clazz != null) {
@@ -988,7 +1065,10 @@
method.setAccessible(true);
Object result = method.invoke(object);
if (result instanceof Boolean && !((Boolean) result).booleanValue()) {
- log.debug("PostConstruct method {}.{} returned false. Returning null model.", method.getDeclaringClass().getName(), method.getName());
+ log.debug(
+ "PostConstruct method {}.{} returned false. Returning null model.",
+ method.getDeclaringClass().getName(),
+ method.getName());
return null;
}
}
@@ -996,7 +1076,8 @@
}
private RuntimeException setField(InjectableField injectableField, Object createdObject, Object value) {
- Result<Object> result = adaptIfNecessary(value, injectableField.getFieldType(), injectableField.getFieldGenericType());
+ Result<Object> result =
+ adaptIfNecessary(value, injectableField.getFieldType(), injectableField.getFieldGenericType());
if (result.wasSuccessful()) {
return injectableField.set(createdObject, result);
} else {
@@ -1015,17 +1096,20 @@
}
}
- private RuntimeException setConstructorParameter(ConstructorParameter constructorParameter, List<Object> parameterValues, Object value) {
+ private RuntimeException setConstructorParameter(
+ ConstructorParameter constructorParameter, List<Object> parameterValues, Object value) {
if (constructorParameter.getParameterType() instanceof Class<?>) {
- Result<Object> result = adaptIfNecessary(value, (Class<?>) constructorParameter.getParameterType(), constructorParameter.getGenericType());
- if (result.wasSuccessful() ) {
+ Result<Object> result = adaptIfNecessary(
+ value, (Class<?>) constructorParameter.getParameterType(), constructorParameter.getGenericType());
+ if (result.wasSuccessful()) {
parameterValues.set(constructorParameter.getParameterIndex(), result.getValue());
return null;
} else {
return result.getThrowable();
}
} else {
- return new ModelClassException(String.format("Constructor parameter with index %d is not a class!", constructorParameter.getParameterIndex()));
+ return new ModelClassException(String.format(
+ "Constructor parameter with index %d is not a class!", constructorParameter.getParameterIndex()));
}
}
@@ -1035,13 +1119,14 @@
if (!isAcceptableType(type, genericType, value)) {
if (genericType instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) genericType;
- if (value instanceof Collection &&
- (type.equals(Collection.class) || type.equals(List.class)) &&
- parameterizedType.getActualTypeArguments().length == 1) {
+ if (value instanceof Collection
+ && (type.equals(Collection.class) || type.equals(List.class))
+ && parameterizedType.getActualTypeArguments().length == 1) {
List<Object> result = new ArrayList<>();
for (Object valueObject : (Collection<?>) value) {
- Result<Object> singleValueResult = adapt(valueObject, (Class<?>) parameterizedType.getActualTypeArguments()[0], true);
+ Result<Object> singleValueResult =
+ adapt(valueObject, (Class<?>) parameterizedType.getActualTypeArguments()[0], true);
if (singleValueResult.wasSuccessful()) {
result.add(singleValueResult.getValue());
} else {
@@ -1050,8 +1135,8 @@
}
adaptedValue = result;
} else {
- return new Result<>(new ModelClassException(String.format("%s is neither a parameterized Collection or List",
- type)));
+ return new Result<>(new ModelClassException(
+ String.format("%s is neither a parameterized Collection or List", type)));
}
} else {
return adapt(value, type, false);
@@ -1078,28 +1163,33 @@
adaptedValue = result.getValue();
} else {
return new Result<>(new ModelClassException(
- String.format("Could not create model from %s: %s%s", value.getClass(), result.getThrowable().getMessage(), messageSuffix),
- result.getThrowable()));
+ String.format(
+ "Could not create model from %s: %s%s",
+ value.getClass(), result.getThrowable().getMessage(), messageSuffix),
+ result.getThrowable()));
}
} else if (value instanceof Adaptable) {
adaptedValue = ((Adaptable) value).adaptTo(type);
if (adaptedValue == null) {
- return new Result<>(new ModelClassException(String.format("Could not adapt from %s to %s%s", value.getClass(), type, messageSuffix)));
+ return new Result<>(new ModelClassException(
+ String.format("Could not adapt from %s to %s%s", value.getClass(), type, messageSuffix)));
}
}
if (adaptedValue != null) {
return new Result<>(adaptedValue);
} else {
- return new Result<>(new ModelClassException(
- String.format("Could not adapt from %s to %s%s, because this class is not adaptable!", value.getClass(), type, messageSuffix)));
+ return new Result<>(new ModelClassException(String.format(
+ "Could not adapt from %s to %s%s, because this class is not adaptable!",
+ value.getClass(), type, messageSuffix)));
}
}
@SuppressWarnings("null")
private static boolean isAcceptableType(Class<?> type, Type genericType, Object value) {
if (type.isInstance(value)) {
- if ((type == Collection.class || type == List.class) && genericType instanceof ParameterizedType &&
- value instanceof Collection) {
+ if ((type == Collection.class || type == List.class)
+ && genericType instanceof ParameterizedType
+ && value instanceof Collection) {
Iterator<?> it = ((Collection<?>) value).iterator();
if (!it.hasNext()) {
// empty collection, so it doesn't really matter
@@ -1107,7 +1197,8 @@
} else {
// this is not an ideal way to get the actual component type, but erasure...
Class<?> actualComponentType = it.next().getClass();
- Class<?> desiredComponentType = (Class<?>) ((ParameterizedType) genericType).getActualTypeArguments()[0];
+ Class<?> desiredComponentType =
+ (Class<?>) ((ParameterizedType) genericType).getActualTypeArguments()[0];
return desiredComponentType.isAssignableFrom(actualComponentType);
}
} else {
@@ -1152,7 +1243,8 @@
}
};
- this.adapterCache = Collections.synchronizedMap(new WeakHashMap<Object, Map<Class<?>, SoftReference<Object>>>());
+ this.adapterCache =
+ Collections.synchronizedMap(new WeakHashMap<Object, Map<Class<?>, SoftReference<Object>>>());
BundleContext bundleContext = ctx.getBundleContext();
this.queue = new ReferenceQueue<>();
@@ -1168,7 +1260,12 @@
this.jobRegistration = bundleContext.registerService(Runnable.class, this, properties);
this.scriptEngineFactory = new SlingModelsScriptEngineFactory(bundleContext.getBundle());
- this.listener = new ModelPackageBundleListener(ctx.getBundleContext(), this, this.adapterImplementations, bindingsValuesProvidersByContext, scriptEngineFactory);
+ this.listener = new ModelPackageBundleListener(
+ ctx.getBundleContext(),
+ this,
+ this.adapterImplementations,
+ bindingsValuesProvidersByContext,
+ scriptEngineFactory);
Hashtable<String, Object> printerProps = new Hashtable<>();
printerProps.put(Constants.SERVICE_VENDOR, "Apache Software Foundation");
@@ -1177,9 +1274,8 @@
printerProps.put("felix.webconsole.title", "Sling Models");
printerProps.put("felix.webconsole.configprinter.modes", "always");
- this.configPrinterRegistration = bundleContext.registerService(Object.class,
- new ModelConfigurationPrinter(this, bundleContext, adapterImplementations), printerProps);
-
+ this.configPrinterRegistration = bundleContext.registerService(
+ Object.class, new ModelConfigurationPrinter(this, bundleContext, adapterImplementations), printerProps);
}
@Deactivate
@@ -1204,11 +1300,11 @@
}
}
- @Reference(cardinality = ReferenceCardinality.MULTIPLE,
- policy = ReferencePolicy.DYNAMIC)
+ @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
protected void bindInjector(final Injector injector, final Map<String, Object> props) {
RankedServices<Injector> newRankedServices = new RankedServices<>();
- RankedServices<Injector> injectorsPerInjectorName = injectors.putIfAbsent(injector.getName(), newRankedServices);
+ RankedServices<Injector> injectorsPerInjectorName =
+ injectors.putIfAbsent(injector.getName(), newRankedServices);
if (injectorsPerInjectorName == null) {
injectorsPerInjectorName = newRankedServices;
}
@@ -1225,40 +1321,45 @@
}
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
- protected void bindStaticInjectAnnotationProcessorFactory(final StaticInjectAnnotationProcessorFactory factory, final Map<String, Object> props) {
+ protected void bindStaticInjectAnnotationProcessorFactory(
+ final StaticInjectAnnotationProcessorFactory factory, final Map<String, Object> props) {
synchronized (staticInjectAnnotationProcessorFactories) {
staticInjectAnnotationProcessorFactories.bind(factory, props);
- this.adapterImplementations.setStaticInjectAnnotationProcessorFactories(staticInjectAnnotationProcessorFactories.get());
+ this.adapterImplementations.setStaticInjectAnnotationProcessorFactories(
+ staticInjectAnnotationProcessorFactories.get());
}
}
- protected void unbindStaticInjectAnnotationProcessorFactory(final StaticInjectAnnotationProcessorFactory factory, final Map<String, Object> props) {
+ protected void unbindStaticInjectAnnotationProcessorFactory(
+ final StaticInjectAnnotationProcessorFactory factory, final Map<String, Object> props) {
synchronized (staticInjectAnnotationProcessorFactories) {
staticInjectAnnotationProcessorFactories.unbind(factory, props);
- this.adapterImplementations.setStaticInjectAnnotationProcessorFactories(staticInjectAnnotationProcessorFactories.get());
+ this.adapterImplementations.setStaticInjectAnnotationProcessorFactories(
+ staticInjectAnnotationProcessorFactories.get());
}
}
- @Reference(name="implementationPicker", cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
- protected void bindImplementationPicker(final ImplementationPicker implementationPicker, final Map<String, Object> props) {
+ @Reference(
+ name = "implementationPicker",
+ cardinality = ReferenceCardinality.MULTIPLE,
+ policy = ReferencePolicy.DYNAMIC)
+ protected void bindImplementationPicker(
+ final ImplementationPicker implementationPicker, final Map<String, Object> props) {
synchronized (implementationPickers) {
implementationPickers.bind(implementationPicker, props);
this.adapterImplementations.setImplementationPickers(implementationPickers.get());
}
}
- protected void unbindImplementationPicker(final ImplementationPicker implementationPicker, final Map<String, Object> props) {
+ protected void unbindImplementationPicker(
+ final ImplementationPicker implementationPicker, final Map<String, Object> props) {
synchronized (implementationPickers) {
implementationPickers.unbind(implementationPicker, props);
this.adapterImplementations.setImplementationPickers(implementationPickers.get());
}
}
- @Reference(
- name = "viaProvider",
- cardinality = ReferenceCardinality.MULTIPLE,
- policy = ReferencePolicy.DYNAMIC
- )
+ @Reference(name = "viaProvider", cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
protected void bindViaProvider(final ViaProvider viaProvider, final Map<String, Object> props) {
Class<? extends ViaProviderType> type = viaProvider.getType();
viaProviders.put(type, viaProvider);
@@ -1269,27 +1370,33 @@
viaProviders.remove(type, viaProvider);
}
- @NotNull Collection<Injector> getInjectors() {
+ @NotNull
+ Collection<Injector> getInjectors() {
return sortedInjectors.get();
}
- @NotNull Collection<InjectAnnotationProcessorFactory> getInjectAnnotationProcessorFactories() {
+ @NotNull
+ Collection<InjectAnnotationProcessorFactory> getInjectAnnotationProcessorFactories() {
return injectAnnotationProcessorFactories;
}
- @NotNull Collection<InjectAnnotationProcessorFactory2> getInjectAnnotationProcessorFactories2() {
+ @NotNull
+ Collection<InjectAnnotationProcessorFactory2> getInjectAnnotationProcessorFactories2() {
return injectAnnotationProcessorFactories2;
}
- @NotNull Collection<StaticInjectAnnotationProcessorFactory> getStaticInjectAnnotationProcessorFactories() {
+ @NotNull
+ Collection<StaticInjectAnnotationProcessorFactory> getStaticInjectAnnotationProcessorFactories() {
return staticInjectAnnotationProcessorFactories.get();
}
- @NotNull ImplementationPicker[] getImplementationPickers() {
+ @NotNull
+ ImplementationPicker[] getImplementationPickers() {
return adapterImplementations.getImplementationPickers();
}
- @NotNull Map<Class<? extends ViaProviderType>, ViaProvider> getViaProviders() {
+ @NotNull
+ Map<Class<? extends ViaProviderType>, ViaProvider> getViaProviders() {
return viaProviders;
}
@@ -1307,7 +1414,8 @@
public Object getModelFromResource(@NotNull Resource resource) {
Class<?> clazz = this.adapterImplementations.getModelClassForResource(resource);
if (clazz == null) {
- throw new ModelClassException("Could find model registered for resource type: " + resource.getResourceType());
+ throw new ModelClassException(
+ "Could find model registered for resource type: " + resource.getResourceType());
}
return handleBoundModelResult(internalCreateModel(resource, clazz));
}
@@ -1343,18 +1451,21 @@
}
@Override
- public <T> T exportModelForResource(Resource resource, String name, Class<T> targetClass, Map<String, String> options)
+ public <T> T exportModelForResource(
+ Resource resource, String name, Class<T> targetClass, Map<String, String> options)
throws ExportException, MissingExporterException {
Class<?> clazz = this.adapterImplementations.getModelClassForResource(resource);
if (clazz == null) {
- throw new ModelClassException("Could find model registered for resource type: " + resource.getResourceType());
+ throw new ModelClassException(
+ "Could find model registered for resource type: " + resource.getResourceType());
}
Result<?> result = internalCreateModel(resource, clazz);
return handleAndExportResult(result, name, targetClass, options);
}
@Override
- public <T> T exportModelForRequest(SlingHttpServletRequest request, String name, Class<T> targetClass, Map<String, String> options)
+ public <T> T exportModelForRequest(
+ SlingHttpServletRequest request, String name, Class<T> targetClass, Map<String, String> options)
throws ExportException, MissingExporterException {
Class<?> clazz = this.adapterImplementations.getModelClassForRequest(request);
if (clazz == null) {
@@ -1364,7 +1475,9 @@
return handleAndExportResult(result, name, targetClass, options);
}
- protected <T> T handleAndExportResult(Result<?> result, String name, Class<T> targetClass, Map<String, String> options) throws ExportException, MissingExporterException {
+ protected <T> T handleAndExportResult(
+ Result<?> result, String name, Class<T> targetClass, Map<String, String> options)
+ throws ExportException, MissingExporterException {
if (result.wasSuccessful()) {
return exportModel(result.getValue(), name, targetClass, options);
} else {
@@ -1373,9 +1486,11 @@
}
@Override
- public <T> T getModelFromWrappedRequest(@NotNull SlingHttpServletRequest request, @NotNull Resource resource, @NotNull Class<T> targetClass) {
- return new ResourceOverridingRequestWrapper(request, resource, adapterManager,
- scriptEngineFactory, bindingsValuesProvidersByContext).adaptTo(targetClass);
+ public <T> T getModelFromWrappedRequest(
+ @NotNull SlingHttpServletRequest request, @NotNull Resource resource, @NotNull Class<T> targetClass) {
+ return new ResourceOverridingRequestWrapper(
+ request, resource, adapterManager, scriptEngineFactory, bindingsValuesProvidersByContext)
+ .adaptTo(targetClass);
}
@Override
@@ -1391,5 +1506,4 @@
public void requestInitialized(ServletRequestEvent sre) {
sre.getServletRequest().setAttribute(REQUEST_MARKER_ATTRIBUTE, REQUEST_MARKER_VALUE);
}
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/ModelAdapterFactoryConfiguration.java b/src/main/java/org/apache/sling/models/impl/ModelAdapterFactoryConfiguration.java
index 9433265..86b25e1 100644
--- a/src/main/java/org/apache/sling/models/impl/ModelAdapterFactoryConfiguration.java
+++ b/src/main/java/org/apache/sling/models/impl/ModelAdapterFactoryConfiguration.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
@@ -21,8 +23,11 @@
@ObjectClassDefinition(name = "Apache Sling Model Adapter Factory")
public @interface ModelAdapterFactoryConfiguration {
- @AttributeDefinition(name="Maximum Recursion Depth", description= "Maximum depth adaptation will be attempted.")
+ @AttributeDefinition(name = "Maximum Recursion Depth", description = "Maximum depth adaptation will be attempted.")
int max_recursion_depth() default 20;
- @AttributeDefinition(name="Cleanup Job Period", description= "Period in seconds at which OSGi service references from ThreadLocals will be cleaned up.")
+
+ @AttributeDefinition(
+ name = "Cleanup Job Period",
+ description = "Period in seconds at which OSGi service references from ThreadLocals will be cleaned up.")
long cleanup_job_period() default 30l;
}
diff --git a/src/main/java/org/apache/sling/models/impl/ModelConfigurationPrinter.java b/src/main/java/org/apache/sling/models/impl/ModelConfigurationPrinter.java
index 36c95b0..3172c3f 100644
--- a/src/main/java/org/apache/sling/models/impl/ModelConfigurationPrinter.java
+++ b/src/main/java/org/apache/sling/models/impl/ModelConfigurationPrinter.java
@@ -1,21 +1,25 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
+import javax.servlet.Servlet;
+
import java.io.PrintWriter;
import java.util.Collection;
import java.util.Map;
@@ -31,25 +35,27 @@
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
-import javax.servlet.Servlet;
-
@SuppressWarnings("deprecation")
public class ModelConfigurationPrinter {
- private static final String EXPORT_SERVLET_FILTER = "(" + ModelPackageBundleListener.PROP_EXPORTER_SERVLET_CLASS + "=*)";
+ private static final String EXPORT_SERVLET_FILTER =
+ "(" + ModelPackageBundleListener.PROP_EXPORTER_SERVLET_CLASS + "=*)";
private final ModelAdapterFactory modelAdapterFactory;
private final BundleContext bundleContext;
private final AdapterImplementations adapterImplementations;
- ModelConfigurationPrinter(ModelAdapterFactory modelAdapterFactory, BundleContext bundleContext, AdapterImplementations adapterImplementations) {
+ ModelConfigurationPrinter(
+ ModelAdapterFactory modelAdapterFactory,
+ BundleContext bundleContext,
+ AdapterImplementations adapterImplementations) {
this.modelAdapterFactory = modelAdapterFactory;
this.bundleContext = bundleContext;
this.adapterImplementations = adapterImplementations;
}
public void printConfiguration(PrintWriter printWriter) {
-
+
// injectors
printWriter.println("Sling Models Injectors:");
Collection<Injector> injectors = modelAdapterFactory.getInjectors();
@@ -57,20 +63,22 @@
printWriter.println("none");
} else {
for (Injector injector : injectors) {
- printWriter.printf("%s - %s", injector.getName(), injector.getClass().getName());
+ printWriter.printf(
+ "%s - %s", injector.getName(), injector.getClass().getName());
printWriter.println();
}
}
printWriter.println();
-
+
// inject annotations processor factories
printWriter.println("Sling Models Inject Annotation Processor Factories:");
- Collection<InjectAnnotationProcessorFactory> factories = modelAdapterFactory.getInjectAnnotationProcessorFactories();
- Collection<InjectAnnotationProcessorFactory2> factories2 = modelAdapterFactory.getInjectAnnotationProcessorFactories2();
- Collection<StaticInjectAnnotationProcessorFactory> staticFactories = modelAdapterFactory.getStaticInjectAnnotationProcessorFactories();
- if ((factories.isEmpty())
- && (factories2.isEmpty())
- && (staticFactories.isEmpty())) {
+ Collection<InjectAnnotationProcessorFactory> factories =
+ modelAdapterFactory.getInjectAnnotationProcessorFactories();
+ Collection<InjectAnnotationProcessorFactory2> factories2 =
+ modelAdapterFactory.getInjectAnnotationProcessorFactories2();
+ Collection<StaticInjectAnnotationProcessorFactory> staticFactories =
+ modelAdapterFactory.getStaticInjectAnnotationProcessorFactories();
+ if ((factories.isEmpty()) && (factories2.isEmpty()) && (staticFactories.isEmpty())) {
printWriter.println("none");
} else {
for (StaticInjectAnnotationProcessorFactory factory : staticFactories) {
@@ -87,7 +95,7 @@
}
}
printWriter.println();
-
+
// implementation pickers
printWriter.println("Sling Models Implementation Pickers:");
ImplementationPicker[] pickers = modelAdapterFactory.getImplementationPickers();
@@ -109,17 +117,19 @@
printWriter.println("none");
} else {
for (Map.Entry<Class<? extends ViaProviderType>, ViaProvider> entry : viaProviders.entrySet()) {
- printWriter.printf("%s (Type: %s)", entry.getValue().getClass().getName(), entry.getKey().getName());
+ printWriter.printf(
+ "%s (Type: %s)",
+ entry.getValue().getClass().getName(), entry.getKey().getName());
printWriter.println();
}
}
-
printWriter.println();
// models bound to resource types
printWriter.println("Sling Models Bound to Resource Types *For Resources*:");
- for (Map.Entry<String, Class<?>> entry : adapterImplementations.getResourceTypeMappingsForResources().entrySet()) {
+ for (Map.Entry<String, Class<?>> entry :
+ adapterImplementations.getResourceTypeMappingsForResources().entrySet()) {
printWriter.print(entry.getValue().getName());
printWriter.print(" - ");
printWriter.println(entry.getKey());
@@ -127,7 +137,8 @@
printWriter.println();
printWriter.println("Sling Models Bound to Resource Types *For Requests*:");
- for (Map.Entry<String, Class<?>> entry : adapterImplementations.getResourceTypeMappingsForRequests().entrySet()) {
+ for (Map.Entry<String, Class<?>> entry :
+ adapterImplementations.getResourceTypeMappingsForRequests().entrySet()) {
printWriter.print(entry.getValue().getName());
printWriter.print(" - ");
printWriter.println(entry.getKey());
@@ -138,7 +149,8 @@
// registered exporter servlets
printWriter.println("Sling Models Exporter Servlets:");
try {
- ServiceReference[] servlets = bundleContext.getServiceReferences(Servlet.class.getName(), EXPORT_SERVLET_FILTER);
+ ServiceReference[] servlets =
+ bundleContext.getServiceReferences(Servlet.class.getName(), EXPORT_SERVLET_FILTER);
if (servlets != null) {
for (ServiceReference ref : servlets) {
printWriter.print(ref.getProperty(ModelPackageBundleListener.PROP_EXPORTER_SERVLET_CLASS));
@@ -157,5 +169,4 @@
// ignore
}
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/models/impl/ModelPackageBundleListener.java b/src/main/java/org/apache/sling/models/impl/ModelPackageBundleListener.java
index b80377a..191b0e2 100644
--- a/src/main/java/org/apache/sling/models/impl/ModelPackageBundleListener.java
+++ b/src/main/java/org/apache/sling/models/impl/ModelPackageBundleListener.java
@@ -1,21 +1,25 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
+import javax.servlet.Servlet;
+
import java.lang.annotation.AnnotationFormatError;
import java.net.URL;
import java.util.ArrayList;
@@ -27,8 +31,6 @@
import java.util.List;
import java.util.Map;
-import javax.servlet.Servlet;
-
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
@@ -87,11 +89,12 @@
private final SlingModelsScriptEngineFactory scriptEngineFactory;
- public ModelPackageBundleListener(BundleContext bundleContext,
- ModelAdapterFactory factory,
- AdapterImplementations adapterImplementations,
- BindingsValuesProvidersByContext bindingsValuesProvidersByContext,
- SlingModelsScriptEngineFactory scriptEngineFactory) {
+ public ModelPackageBundleListener(
+ BundleContext bundleContext,
+ ModelAdapterFactory factory,
+ AdapterImplementations adapterImplementations,
+ BindingsValuesProvidersByContext bindingsValuesProvidersByContext,
+ SlingModelsScriptEngineFactory scriptEngineFactory) {
this.bundleContext = bundleContext;
this.factory = factory;
this.adapterImplementations = adapterImplementations;
@@ -122,7 +125,6 @@
URL url = classUrls.nextElement();
String className = toClassName(url);
analyzeClass(bundle, className, regs);
-
}
}
}
@@ -147,21 +149,23 @@
// get list of adapters from annotation - if not given use annotated class itself
Class<?>[] adapterTypes = annotation.adapters();
if (adapterTypes.length == 0) {
- adapterTypes = new Class<?>[] { implType };
+ adapterTypes = new Class<?>[] {implType};
} else if (!ArrayUtils.contains(adapterTypes, implType)) {
adapterTypes = ArrayUtils.add(adapterTypes, implType);
}
// register adapter only if given adapters are valid
if (validateAdapterClasses(implType, adapterTypes)) {
if (adapterImplementations.addAll(implType, adapterTypes)) {
- ServiceRegistration reg = registerAdapterFactory(adapterTypes, annotation.adaptables(), implType, annotation.condition());
+ ServiceRegistration reg = registerAdapterFactory(
+ adapterTypes, annotation.adaptables(), implType, annotation.condition());
regs.add(reg);
String[] resourceTypes = annotation.resourceType();
for (String resourceType : resourceTypes) {
if (StringUtils.isNotEmpty(resourceType)) {
for (Class<?> adaptable : annotation.adaptables()) {
- adapterImplementations.registerModelToResourceType(bundle, resourceType, adaptable, implType);
+ adapterImplementations.registerModelToResourceType(
+ bundle, resourceType, adaptable, implType);
ExportServlet.ExportedObjectAccessor accessor = null;
if (adaptable == Resource.class) {
accessor = new ExportServlet.ResourceAccessor(implType);
@@ -170,7 +174,8 @@
}
Exporter exporterAnnotation = implType.getAnnotation(Exporter.class);
if (exporterAnnotation != null) {
- registerExporter(bundle, implType, resourceType, exporterAnnotation, regs, accessor);
+ registerExporter(
+ bundle, implType, resourceType, exporterAnnotation, regs, accessor);
}
Exporters exportersAnnotation = implType.getAnnotation(Exporters.class);
if (exportersAnnotation != null) {
@@ -178,22 +183,24 @@
registerExporter(bundle, implType, resourceType, ann, regs, accessor);
}
}
-
}
}
}
}
}
-
}
- } catch (ClassNotFoundException|AnnotationFormatError e) {
- log.warn("Unable to load class '{}' from bundle '{}': {}", className, bundle.getSymbolicName(), e.getLocalizedMessage(), e);
+ } catch (ClassNotFoundException | AnnotationFormatError e) {
+ log.warn(
+ "Unable to load class '{}' from bundle '{}': {}",
+ className,
+ bundle.getSymbolicName(),
+ e.getLocalizedMessage(),
+ e);
}
}
@Override
- public void modifiedBundle(Bundle bundle, BundleEvent event, ServiceRegistration[] object) {
- }
+ public void modifiedBundle(Bundle bundle, BundleEvent event, ServiceRegistration[] object) {}
@Override
public void removedBundle(Bundle bundle, BundleEvent event, ServiceRegistration[] object) {
@@ -209,7 +216,6 @@
reg.unregister();
}
adapterImplementations.removeResourceTypeBindings(bundle);
-
}
public synchronized void unregisterAll() {
@@ -242,8 +248,10 @@
private boolean validateAdapterClasses(Class<?> clazz, Class<?>[] adapterClasses) {
for (Class<?> adapterClass : adapterClasses) {
if (!adapterClass.isAssignableFrom(clazz)) {
- log.warn("Unable to register model class {} because adapter class {} is not valid.",
- clazz.getName(), adapterClass.getName());
+ log.warn(
+ "Unable to register model class {} because adapter class {} is not valid.",
+ clazz.getName(),
+ adapterClass.getName());
return false;
}
}
@@ -258,7 +266,8 @@
* @param condition Condition (optional)
* @return Service registration
*/
- private ServiceRegistration registerAdapterFactory(Class<?>[] adapterTypes, Class<?>[] adaptableTypes, Class<?> implType, String condition) {
+ private ServiceRegistration registerAdapterFactory(
+ Class<?>[] adapterTypes, Class<?>[] adaptableTypes, Class<?> implType, String condition) {
Dictionary<String, Object> registrationProps = new Hashtable<>();
registrationProps.put(AdapterFactory.ADAPTER_CLASSES, toStringArray(adapterTypes));
registrationProps.put(AdapterFactory.ADAPTABLE_CLASSES, toStringArray(adaptableTypes));
@@ -271,13 +280,25 @@
return bundleContext.registerService(AdapterFactory.SERVICE_NAME, factory, registrationProps);
}
-
- private void registerExporter(Bundle bundle, Class<?> annotatedClass, String resourceType, Exporter exporterAnnotation,
- List<ServiceRegistration> regs, ExportServlet.ExportedObjectAccessor accessor) {
+ private void registerExporter(
+ Bundle bundle,
+ Class<?> annotatedClass,
+ String resourceType,
+ Exporter exporterAnnotation,
+ List<ServiceRegistration> regs,
+ ExportServlet.ExportedObjectAccessor accessor) {
if (accessor != null) {
Map<String, String> baseOptions = getOptions(exporterAnnotation);
- ExportServlet servlet = new ExportServlet(bundle.getBundleContext(), factory, bindingsValuesProvidersByContext,
- scriptEngineFactory, annotatedClass, exporterAnnotation.selector(), exporterAnnotation.name(), accessor, baseOptions);
+ ExportServlet servlet = new ExportServlet(
+ bundle.getBundleContext(),
+ factory,
+ bindingsValuesProvidersByContext,
+ scriptEngineFactory,
+ annotatedClass,
+ exporterAnnotation.selector(),
+ exporterAnnotation.name(),
+ accessor,
+ baseOptions);
Dictionary<String, Object> registrationProps = new Hashtable<>();
registrationProps.put("sling.servlet.resourceTypes", resourceType);
registrationProps.put("sling.servlet.selectors", exporterAnnotation.selector());
@@ -285,9 +306,12 @@
registrationProps.put(PROP_EXPORTER_SERVLET_CLASS, annotatedClass.getName());
registrationProps.put(PROP_EXPORTER_SERVLET_NAME, exporterAnnotation.name());
- log.debug("registering servlet for {}, {}, {}", new Object[]{resourceType, exporterAnnotation.selector(), exporterAnnotation.extensions()});
+ log.debug(
+ "registering servlet for {}, {}, {}",
+ new Object[] {resourceType, exporterAnnotation.selector(), exporterAnnotation.extensions()});
- ServiceRegistration reg = bundleContext.registerService(Servlet.class.getName(), servlet, registrationProps);
+ ServiceRegistration reg =
+ bundleContext.registerService(Servlet.class.getName(), servlet, registrationProps);
regs.add(reg);
}
}
@@ -304,5 +328,4 @@
return map;
}
}
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/ReflectionUtil.java b/src/main/java/org/apache/sling/models/impl/ReflectionUtil.java
index 456b1c7..528c1f1 100644
--- a/src/main/java/org/apache/sling/models/impl/ReflectionUtil.java
+++ b/src/main/java/org/apache/sling/models/impl/ReflectionUtil.java
@@ -18,6 +18,8 @@
*/
package org.apache.sling.models.impl;
+import javax.inject.Inject;
+
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
@@ -26,8 +28,6 @@
import java.util.ArrayList;
import java.util.List;
-import javax.inject.Inject;
-
import org.apache.commons.lang3.ClassUtils;
import org.apache.sling.models.spi.injectorspecific.InjectAnnotation;
@@ -59,7 +59,6 @@
type = type.getSuperclass();
}
return result;
-
}
private static void addAnnotatedMethodsFromInterfaces(Class<?> type, List<Method> result) {
@@ -124,5 +123,4 @@
return type;
}
}
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/ResourceOverridingRequestWrapper.java b/src/main/java/org/apache/sling/models/impl/ResourceOverridingRequestWrapper.java
index c37e588..18b19c6 100644
--- a/src/main/java/org/apache/sling/models/impl/ResourceOverridingRequestWrapper.java
+++ b/src/main/java/org/apache/sling/models/impl/ResourceOverridingRequestWrapper.java
@@ -1,29 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.apache.sling.api.scripting.SlingBindings.LOG;
-import static org.apache.sling.api.scripting.SlingBindings.OUT;
-import static org.apache.sling.api.scripting.SlingBindings.READER;
-import static org.apache.sling.api.scripting.SlingBindings.REQUEST;
-import static org.apache.sling.api.scripting.SlingBindings.RESOURCE;
-import static org.apache.sling.api.scripting.SlingBindings.RESPONSE;
-import static org.apache.sling.api.scripting.SlingBindings.SLING;
-
import javax.script.Bindings;
import org.apache.sling.api.SlingHttpServletRequest;
@@ -33,6 +27,14 @@
import org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper;
import org.apache.sling.scripting.api.BindingsValuesProvidersByContext;
+import static org.apache.sling.api.scripting.SlingBindings.LOG;
+import static org.apache.sling.api.scripting.SlingBindings.OUT;
+import static org.apache.sling.api.scripting.SlingBindings.READER;
+import static org.apache.sling.api.scripting.SlingBindings.REQUEST;
+import static org.apache.sling.api.scripting.SlingBindings.RESOURCE;
+import static org.apache.sling.api.scripting.SlingBindings.RESPONSE;
+import static org.apache.sling.api.scripting.SlingBindings.SLING;
+
/**
* This request wrapper allows to adapt the given resource and request to a Sling Model
*/
@@ -42,9 +44,12 @@
private final AdapterManager adapterManager;
private final Bindings bindings;
- ResourceOverridingRequestWrapper(SlingHttpServletRequest wrappedRequest, Resource resource,
- AdapterManager adapterManager, SlingModelsScriptEngineFactory scriptEngineFactory,
- BindingsValuesProvidersByContext bindingsValuesProvidersByContext) {
+ ResourceOverridingRequestWrapper(
+ SlingHttpServletRequest wrappedRequest,
+ Resource resource,
+ AdapterManager adapterManager,
+ SlingModelsScriptEngineFactory scriptEngineFactory,
+ BindingsValuesProvidersByContext bindingsValuesProvidersByContext) {
super(wrappedRequest);
this.resource = resource;
this.adapterManager = adapterManager;
@@ -74,6 +79,7 @@
return super.getAttribute(name);
}
}
+
@Override
public Resource getResource() {
return resource;
@@ -83,4 +89,4 @@
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
return adapterManager.getAdapter(this, type);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/models/impl/ResourceTypeBasedResourcePicker.java b/src/main/java/org/apache/sling/models/impl/ResourceTypeBasedResourcePicker.java
index 00df685..5a97c72 100644
--- a/src/main/java/org/apache/sling/models/impl/ResourceTypeBasedResourcePicker.java
+++ b/src/main/java/org/apache/sling/models/impl/ResourceTypeBasedResourcePicker.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
@@ -27,11 +29,12 @@
import org.osgi.framework.Constants;
import org.osgi.service.component.annotations.Component;
-@Component(property=Constants.SERVICE_RANKING+":Integer=0") // this must come before FirstImplementationPicker
+@Component(property = Constants.SERVICE_RANKING + ":Integer=0") // this must come before FirstImplementationPicker
public class ResourceTypeBasedResourcePicker implements ImplementationPicker {
@Override
- public Class<?> pick(@NotNull Class<?> adapterType, Class<?> @NotNull [] implementationsTypes, @NotNull Object adaptable) {
+ public Class<?> pick(
+ @NotNull Class<?> adapterType, Class<?> @NotNull [] implementationsTypes, @NotNull Object adaptable) {
final Resource resource = findResource(adaptable);
if (resource == null) {
return null;
@@ -68,5 +71,4 @@
}
return retval;
}
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/Result.java b/src/main/java/org/apache/sling/models/impl/Result.java
index df9612c..cba2573 100644
--- a/src/main/java/org/apache/sling/models/impl/Result.java
+++ b/src/main/java/org/apache/sling/models/impl/Result.java
@@ -89,13 +89,13 @@
return object != null;
}
- public static final Result<Object> POST_CONSTRUCT_PREVENTED_MODEL_CONSTRUCTION = new Result<Object>((RuntimeException)null) {
+ public static final Result<Object> POST_CONSTRUCT_PREVENTED_MODEL_CONSTRUCTION =
+ new Result<Object>((RuntimeException) null) {
- @Override
- public @NotNull RuntimeException getThrowable() {
- // generate exception lazily
- return new PostConstructException("PostConstruct method returned false", null);
- }
-
- };
+ @Override
+ public @NotNull RuntimeException getThrowable() {
+ // generate exception lazily
+ return new PostConstructException("PostConstruct method returned false", null);
+ }
+ };
}
diff --git a/src/main/java/org/apache/sling/models/impl/SlingModelsScriptEngineFactory.java b/src/main/java/org/apache/sling/models/impl/SlingModelsScriptEngineFactory.java
index bd6d40d..35c52a8 100644
--- a/src/main/java/org/apache/sling/models/impl/SlingModelsScriptEngineFactory.java
+++ b/src/main/java/org/apache/sling/models/impl/SlingModelsScriptEngineFactory.java
@@ -1,28 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import org.apache.sling.scripting.api.AbstractScriptEngineFactory;
-import org.apache.sling.scripting.api.BindingsValuesProvider;
-import org.apache.sling.scripting.api.BindingsValuesProvidersByContext;
-import org.apache.sling.scripting.core.impl.helper.ProtectedBindings;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-
import javax.script.Bindings;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
@@ -32,6 +27,13 @@
import java.util.HashSet;
import java.util.Set;
+import org.apache.sling.scripting.api.AbstractScriptEngineFactory;
+import org.apache.sling.scripting.api.BindingsValuesProvider;
+import org.apache.sling.scripting.api.BindingsValuesProvidersByContext;
+import org.apache.sling.scripting.core.impl.helper.ProtectedBindings;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
import static org.apache.sling.api.scripting.SlingBindings.*;
/**
@@ -53,7 +55,9 @@
super();
setEngineName("Apache Sling Models");
// really the only time this is null is during testing
- if (bundle != null && bundle.getHeaders() != null && bundle.getHeaders().get(Constants.BUNDLE_VERSION) != null) {
+ if (bundle != null
+ && bundle.getHeaders() != null
+ && bundle.getHeaders().get(Constants.BUNDLE_VERSION) != null) {
setEngineVersion(bundle.getHeaders().get(Constants.BUNDLE_VERSION).toString());
}
setNames("sling-models-exporter", "sling-models");
@@ -74,9 +78,11 @@
return null;
}
- void invokeBindingsValuesProviders(BindingsValuesProvidersByContext bindingsValuesProvidersByContext, Bindings bindings) {
+ void invokeBindingsValuesProviders(
+ BindingsValuesProvidersByContext bindingsValuesProvidersByContext, Bindings bindings) {
final Collection<BindingsValuesProvider> bindingsValuesProviders =
- bindingsValuesProvidersByContext.getBindingsValuesProviders(this, SlingModelsScriptEngineFactory.BINDINGS_CONTEXT);
+ bindingsValuesProvidersByContext.getBindingsValuesProviders(
+ this, SlingModelsScriptEngineFactory.BINDINGS_CONTEXT);
if (!bindingsValuesProviders.isEmpty()) {
Set<String> protectedKeys = new HashSet<String>();
@@ -86,7 +92,6 @@
for (BindingsValuesProvider provider : bindingsValuesProviders) {
provider.addBindings(protectedBindings);
}
-
}
}
}
diff --git a/src/main/java/org/apache/sling/models/impl/ThreadInvocationCounter.java b/src/main/java/org/apache/sling/models/impl/ThreadInvocationCounter.java
index b386aa5..e10fe0e 100644
--- a/src/main/java/org/apache/sling/models/impl/ThreadInvocationCounter.java
+++ b/src/main/java/org/apache/sling/models/impl/ThreadInvocationCounter.java
@@ -39,4 +39,4 @@
public void decrease() {
this.count--;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/models/impl/injectors/AbstractInjector.java b/src/main/java/org/apache/sling/models/impl/injectors/AbstractInjector.java
index b1d37c3..f653bb0 100644
--- a/src/main/java/org/apache/sling/models/impl/injectors/AbstractInjector.java
+++ b/src/main/java/org/apache/sling/models/impl/injectors/AbstractInjector.java
@@ -60,7 +60,7 @@
if (adaptable instanceof ValueMap) {
return (ValueMap) adaptable;
} else if (adaptable instanceof SlingHttpServletRequest) {
- final Resource resource = ((SlingHttpServletRequest)adaptable).getResource();
+ final Resource resource = ((SlingHttpServletRequest) adaptable).getResource();
// resource may be null for mocked adaptables, therefore do a check here
if (resource != null) {
return resource.adaptTo(ValueMap.class);
@@ -79,10 +79,8 @@
if (declaredType instanceof ParameterizedType) {
ParameterizedType type = (ParameterizedType) declaredType;
Class<?> collectionType = (Class<?>) type.getRawType();
- isCollection = collectionType.equals(Collection.class)
- || collectionType.equals(List.class);
+ isCollection = collectionType.equals(Collection.class) || collectionType.equals(List.class);
}
return isCollection;
}
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/injectors/BindingsInjector.java b/src/main/java/org/apache/sling/models/impl/injectors/BindingsInjector.java
index 1fd5495..5cae97b 100644
--- a/src/main/java/org/apache/sling/models/impl/injectors/BindingsInjector.java
+++ b/src/main/java/org/apache/sling/models/impl/injectors/BindingsInjector.java
@@ -1,26 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.injectors;
+import javax.servlet.ServletRequest;
+
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Type;
-import javax.servlet.ServletRequest;
-
import org.apache.commons.lang3.ObjectUtils;
import org.apache.sling.api.scripting.SlingBindings;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
@@ -35,7 +37,9 @@
import org.osgi.framework.Constants;
import org.osgi.service.component.annotations.Component;
-@Component(property=Constants.SERVICE_RANKING+":Integer=1000", service={Injector.class, StaticInjectAnnotationProcessorFactory.class, ValuePreparer.class})
+@Component(
+ property = Constants.SERVICE_RANKING + ":Integer=1000",
+ service = {Injector.class, StaticInjectAnnotationProcessorFactory.class, ValuePreparer.class})
public class BindingsInjector implements Injector, StaticInjectAnnotationProcessorFactory, ValuePreparer {
@Override
@@ -44,7 +48,11 @@
}
@Override
- public Object getValue(@NotNull Object adaptable, String name, @NotNull Type type, @NotNull AnnotatedElement element,
+ public Object getValue(
+ @NotNull Object adaptable,
+ String name,
+ @NotNull Type type,
+ @NotNull AnnotatedElement element,
@NotNull DisposalCallbackRegistry callbackRegistry) {
if (adaptable == ObjectUtils.NULL) {
return null;
@@ -113,5 +121,4 @@
return annotation.name();
}
}
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/injectors/ChildResourceInjector.java b/src/main/java/org/apache/sling/models/impl/injectors/ChildResourceInjector.java
index b32cf7e..e4e4585 100644
--- a/src/main/java/org/apache/sling/models/impl/injectors/ChildResourceInjector.java
+++ b/src/main/java/org/apache/sling/models/impl/injectors/ChildResourceInjector.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.injectors;
@@ -37,7 +39,9 @@
import org.osgi.framework.Constants;
import org.osgi.service.component.annotations.Component;
-@Component(property=Constants.SERVICE_RANKING+":Integer=3000", service={Injector.class, InjectAnnotationProcessorFactory2.class})
+@Component(
+ property = Constants.SERVICE_RANKING + ":Integer=3000",
+ service = {Injector.class, InjectAnnotationProcessorFactory2.class})
public class ChildResourceInjector extends AbstractInjector implements Injector, InjectAnnotationProcessorFactory2 {
@Override
@@ -46,7 +50,11 @@
}
@Override
- public Object getValue(@NotNull Object adaptable, String name, @NotNull Type declaredType, @NotNull AnnotatedElement element,
+ public Object getValue(
+ @NotNull Object adaptable,
+ String name,
+ @NotNull Type declaredType,
+ @NotNull AnnotatedElement element,
@NotNull DisposalCallbackRegistry callbackRegistry) {
if (adaptable instanceof Resource) {
Resource child = ((Resource) adaptable).getChild(name);
@@ -68,25 +76,24 @@
}
private Object getResultList(Resource resource, Type declaredType) {
- List<Resource> result = new ArrayList<>();
- Class<?> type = getActualType((ParameterizedType) declaredType);
- if (type != null && resource != null) {
- Iterator<Resource> children = resource.listChildren();
- while (children.hasNext()) {
- result.add(children.next());
- }
- }
- return result;
- }
+ List<Resource> result = new ArrayList<>();
+ Class<?> type = getActualType((ParameterizedType) declaredType);
+ if (type != null && resource != null) {
+ Iterator<Resource> children = resource.listChildren();
+ while (children.hasNext()) {
+ result.add(children.next());
+ }
+ }
+ return result;
+ }
- private Class<?> getActualType(ParameterizedType declaredType) {
- Type[] types = declaredType.getActualTypeArguments();
- if (types != null && types.length > 0) {
- return (Class<?>) types[0];
- }
- return null;
- }
-
+ private Class<?> getActualType(ParameterizedType declaredType) {
+ Type[] types = declaredType.getActualTypeArguments();
+ if (types != null && types.length > 0) {
+ return (Class<?>) types[0];
+ }
+ return null;
+ }
@Override
@SuppressWarnings("unused")
@@ -143,5 +150,4 @@
}
}
}
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java b/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
index 086982c..f2c3acf 100644
--- a/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
+++ b/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.injectors;
@@ -48,7 +50,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Component(property=Constants.SERVICE_RANKING+":Integer=5000", service={Injector.class, StaticInjectAnnotationProcessorFactory.class, AcceptsNullName.class})
+@Component(
+ property = Constants.SERVICE_RANKING + ":Integer=5000",
+ service = {Injector.class, StaticInjectAnnotationProcessorFactory.class, AcceptsNullName.class})
public class OSGiServiceInjector implements Injector, StaticInjectAnnotationProcessorFactory, AcceptsNullName {
private static final Logger log = LoggerFactory.getLogger(OSGiServiceInjector.class);
@@ -66,7 +70,11 @@
}
@Override
- public Object getValue(@NotNull Object adaptable, String name, @NotNull Type type, @NotNull AnnotatedElement element,
+ public Object getValue(
+ @NotNull Object adaptable,
+ String name,
+ @NotNull Type type,
+ @NotNull AnnotatedElement element,
@NotNull DisposalCallbackRegistry callbackRegistry) {
return getValue(adaptable, name, type, element, callbackRegistry, bundleContext);
}
@@ -80,9 +88,14 @@
* @param modelContext Model context
* @return Object
*/
- @SuppressWarnings({ "null", "unused" })
- public Object getValue(@NotNull Object adaptable, String name, @NotNull Type type, @NotNull AnnotatedElement element,
- @NotNull DisposalCallbackRegistry callbackRegistry, @Nullable BundleContext modelContext) {
+ @SuppressWarnings({"null", "unused"})
+ public Object getValue(
+ @NotNull Object adaptable,
+ String name,
+ @NotNull Type type,
+ @NotNull AnnotatedElement element,
+ @NotNull DisposalCallbackRegistry callbackRegistry,
+ @Nullable BundleContext modelContext) {
OSGiService annotation = element.getAnnotation(OSGiService.class);
String filterString = null;
if (annotation != null) {
@@ -95,21 +108,27 @@
filterString = filter.value();
}
}
- return getValue(adaptable, type, filterString, callbackRegistry, modelContext == null ? bundleContext : modelContext);
+ return getValue(
+ adaptable, type, filterString, callbackRegistry, modelContext == null ? bundleContext : modelContext);
}
- private <T> Object getService(Object adaptable, Class<T> type, String filter,
- DisposalCallbackRegistry callbackRegistry, BundleContext modelContext) {
- // cannot use SlingScriptHelper since it does not support ordering by service ranking due to https://issues.apache.org/jira/browse/SLING-5665
+ private <T> Object getService(
+ Object adaptable,
+ Class<T> type,
+ String filter,
+ DisposalCallbackRegistry callbackRegistry,
+ BundleContext modelContext) {
+ // cannot use SlingScriptHelper since it does not support ordering by service ranking due to
+ // https://issues.apache.org/jira/browse/SLING-5665
try {
ServiceReference<?>[] refs = modelContext.getServiceReferences(type.getName(), filter);
if (refs != null && refs.length > 0) {
// sort by reverse service ranking (highest first) (see ServiceReference.compareTo)
List<ServiceReference<?>> references = Arrays.asList(refs);
Collections.sort(references, Collections.reverseOrder());
- for(final ServiceReference<?> ref : references) {
+ for (final ServiceReference<?> ref : references) {
final Object obj = modelContext.getService(ref);
- if ( obj != null ) {
+ if (obj != null) {
callbackRegistry.addDisposalCallback(new Callback(new ServiceReference[] {ref}, modelContext));
return obj;
}
@@ -121,9 +140,14 @@
return null;
}
- private <T> Object[] getServices(Object adaptable, Class<T> type, String filter,
- DisposalCallbackRegistry callbackRegistry, BundleContext modelContext) {
- // cannot use SlingScriptHelper since it does not support ordering by service ranking due to https://issues.apache.org/jira/browse/SLING-5665
+ private <T> Object[] getServices(
+ Object adaptable,
+ Class<T> type,
+ String filter,
+ DisposalCallbackRegistry callbackRegistry,
+ BundleContext modelContext) {
+ // cannot use SlingScriptHelper since it does not support ordering by service ranking due to
+ // https://issues.apache.org/jira/browse/SLING-5665
try {
ServiceReference<?>[] refs = modelContext.getServiceReferences(type.getName(), filter);
if (refs != null && refs.length > 0) {
@@ -139,8 +163,9 @@
usedRefs.add(ref);
}
}
- if ( !services.isEmpty() ) {
- callbackRegistry.addDisposalCallback(new Callback(usedRefs.toArray(new ServiceReference[usedRefs.size()]), modelContext));
+ if (!services.isEmpty()) {
+ callbackRegistry.addDisposalCallback(
+ new Callback(usedRefs.toArray(new ServiceReference[usedRefs.size()]), modelContext));
return services.toArray(new Object[services.size()]);
}
}
@@ -150,13 +175,17 @@
return null;
}
- private Object getValue(Object adaptable, Type type, String filterString, DisposalCallbackRegistry callbackRegistry,
- BundleContext modelContext) {
+ private Object getValue(
+ Object adaptable,
+ Type type,
+ String filterString,
+ DisposalCallbackRegistry callbackRegistry,
+ BundleContext modelContext) {
if (type instanceof Class) {
Class<?> injectedClass = (Class<?>) type;
if (injectedClass.isArray()) {
- Object[] services = getServices(adaptable, injectedClass.getComponentType(), filterString,
- callbackRegistry, modelContext);
+ Object[] services = getServices(
+ adaptable, injectedClass.getComponentType(), filterString, callbackRegistry, modelContext);
if (services == null) {
return null;
}
@@ -214,7 +243,7 @@
}
@Override
- @SuppressWarnings({ "unused", "null" })
+ @SuppressWarnings({"unused", "null"})
public InjectAnnotationProcessor2 createAnnotationProcessor(AnnotatedElement element) {
// check if the element has the expected annotation
OSGiService annotation = element.getAnnotation(OSGiService.class);
@@ -243,6 +272,4 @@
return annotation.optional();
}
}
-
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/injectors/RequestAttributeInjector.java b/src/main/java/org/apache/sling/models/impl/injectors/RequestAttributeInjector.java
index 9df6b37..35d9e97 100644
--- a/src/main/java/org/apache/sling/models/impl/injectors/RequestAttributeInjector.java
+++ b/src/main/java/org/apache/sling/models/impl/injectors/RequestAttributeInjector.java
@@ -1,26 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.injectors;
+import javax.servlet.ServletRequest;
+
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Type;
-import javax.servlet.ServletRequest;
-
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.RequestAttribute;
import org.apache.sling.models.spi.DisposalCallbackRegistry;
@@ -32,7 +34,9 @@
import org.osgi.framework.Constants;
import org.osgi.service.component.annotations.Component;
-@Component(property=Constants.SERVICE_RANKING+":Integer=4000", service={Injector.class, StaticInjectAnnotationProcessorFactory.class})
+@Component(
+ property = Constants.SERVICE_RANKING + ":Integer=4000",
+ service = {Injector.class, StaticInjectAnnotationProcessorFactory.class})
public class RequestAttributeInjector implements Injector, StaticInjectAnnotationProcessorFactory {
@Override
@@ -41,7 +45,11 @@
}
@Override
- public Object getValue(@NotNull Object adaptable, String name, @NotNull Type declaredType, @NotNull AnnotatedElement element,
+ public Object getValue(
+ @NotNull Object adaptable,
+ String name,
+ @NotNull Type declaredType,
+ @NotNull AnnotatedElement element,
@NotNull DisposalCallbackRegistry callbackRegistry) {
if (!(adaptable instanceof ServletRequest)) {
return null;
@@ -51,7 +59,7 @@
}
@Override
- @SuppressWarnings({ "unused", "null" })
+ @SuppressWarnings({"unused", "null"})
public InjectAnnotationProcessor2 createAnnotationProcessor(AnnotatedElement element) {
// check if the element has the expected annotation
RequestAttribute annotation = element.getAnnotation(RequestAttribute.class);
@@ -90,6 +98,4 @@
return annotation.name();
}
}
-
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/injectors/ResourcePathInjector.java b/src/main/java/org/apache/sling/models/impl/injectors/ResourcePathInjector.java
index f49a1d7..fc65281 100644
--- a/src/main/java/org/apache/sling/models/impl/injectors/ResourcePathInjector.java
+++ b/src/main/java/org/apache/sling/models/impl/injectors/ResourcePathInjector.java
@@ -43,9 +43,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Component(property=Constants.SERVICE_RANKING+":Integer=2500", service={Injector.class, StaticInjectAnnotationProcessorFactory.class, AcceptsNullName.class})
-public class ResourcePathInjector extends AbstractInjector implements Injector, AcceptsNullName,
- StaticInjectAnnotationProcessorFactory {
+@Component(
+ property = Constants.SERVICE_RANKING + ":Integer=2500",
+ service = {Injector.class, StaticInjectAnnotationProcessorFactory.class, AcceptsNullName.class})
+public class ResourcePathInjector extends AbstractInjector
+ implements Injector, AcceptsNullName, StaticInjectAnnotationProcessorFactory {
private static final Logger LOG = LoggerFactory.getLogger(ResourcePathInjector.class);
@@ -55,8 +57,12 @@
}
@Override
- @SuppressWarnings({ "unused", "null" })
- public Object getValue(@NotNull Object adaptable, String name, @NotNull Type declaredType, @NotNull AnnotatedElement element,
+ @SuppressWarnings({"unused", "null"})
+ public Object getValue(
+ @NotNull Object adaptable,
+ String name,
+ @NotNull Type declaredType,
+ @NotNull AnnotatedElement element,
@NotNull DisposalCallbackRegistry callbackRegistry) {
String[] resourcePaths = null;
Path pathAnnotation = element.getAnnotation(Path.class);
@@ -91,17 +97,17 @@
// unwrap/wrap if necessary
if (isDeclaredTypeCollection(declaredType)) {
return resources;
- } if (declaredType instanceof Class<?> && ((Class<?>)declaredType).isArray()){
+ }
+ if (declaredType instanceof Class<?> && ((Class<?>) declaredType).isArray()) {
return resources.toArray(new Resource[0]);
}
- if (resources.size() == 1) {
+ if (resources.size() == 1) {
return resources.get(0);
} else {
// multiple resources to inject, but field is not a list
LOG.warn("Cannot inject multiple resources into field {} since it is not declared as a list", name);
return null;
}
-
}
private List<Resource> getResources(ResourceResolver resolver, String[] paths, String fieldName) {
@@ -111,8 +117,10 @@
if (resource != null) {
resources.add(resource);
} else {
- LOG.warn("Could not retrieve resource at path {} for field {}. Since it is required it won't be injected.",
- path, fieldName);
+ LOG.warn(
+ "Could not retrieve resource at path {} for field {}. Since it is required it won't be injected.",
+ path,
+ fieldName);
// all resources should've been injected. we stop
return null;
}
@@ -128,7 +136,7 @@
private String[] getPathsFromAnnotation(Path pathAnnotation) {
String[] resourcePaths = null;
if (StringUtils.isNotEmpty(pathAnnotation.value())) {
- resourcePaths = new String[] { pathAnnotation.value() };
+ resourcePaths = new String[] {pathAnnotation.value()};
} else {
resourcePaths = pathAnnotation.paths();
}
@@ -143,7 +151,7 @@
private String[] getPathsFromAnnotation(ResourcePath resourcePathAnnotation) {
String[] resourcePaths = null;
if (StringUtils.isNotEmpty(resourcePathAnnotation.path())) {
- resourcePaths = new String[] { resourcePathAnnotation.path() };
+ resourcePaths = new String[] {resourcePathAnnotation.path()};
} else {
resourcePaths = resourcePathAnnotation.paths();
}
@@ -151,7 +159,7 @@
}
@Override
- @SuppressWarnings({ "unused", "null" })
+ @SuppressWarnings({"unused", "null"})
public InjectAnnotationProcessor2 createAnnotationProcessor(AnnotatedElement element) {
// check if the element has the expected annotation
ResourcePath annotation = element.getAnnotation(ResourcePath.class);
@@ -190,5 +198,4 @@
return annotation.injectionStrategy();
}
}
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/injectors/SelfInjector.java b/src/main/java/org/apache/sling/models/impl/injectors/SelfInjector.java
index d59192f..33c2708 100644
--- a/src/main/java/org/apache/sling/models/impl/injectors/SelfInjector.java
+++ b/src/main/java/org/apache/sling/models/impl/injectors/SelfInjector.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.injectors;
@@ -35,7 +37,9 @@
/**
* Injects the adaptable object itself.
*/
-@Component(property=Constants.SERVICE_RANKING+":Integer="+Integer.MAX_VALUE, service={Injector.class, StaticInjectAnnotationProcessorFactory.class, AcceptsNullName.class})
+@Component(
+ property = Constants.SERVICE_RANKING + ":Integer=" + Integer.MAX_VALUE,
+ service = {Injector.class, StaticInjectAnnotationProcessorFactory.class, AcceptsNullName.class})
public class SelfInjector implements Injector, StaticInjectAnnotationProcessorFactory, AcceptsNullName {
@Override
@@ -43,7 +47,11 @@
return "self";
}
- public Object getValue(@NotNull Object adaptable, String name, @NotNull Type type, @NotNull AnnotatedElement element,
+ public Object getValue(
+ @NotNull Object adaptable,
+ String name,
+ @NotNull Type type,
+ @NotNull AnnotatedElement element,
@NotNull DisposalCallbackRegistry callbackRegistry) {
// if the @Self annotation is present return the adaptable to be inserted directly or to be adapted from
if (element.isAnnotationPresent(Self.class)) {
@@ -51,10 +59,10 @@
} else {
// special handling for the first constructor parameter
// apply class-based injection only if class matches or is a superclass
- if (element instanceof ConstructorParameter.FakeAnnotatedElement &&
- ((ConstructorParameter.FakeAnnotatedElement)element).getParameterIndex() == 0 &&
- type instanceof Class<?> &&
- ((Class<?>)type).isAssignableFrom(adaptable.getClass())) {
+ if (element instanceof ConstructorParameter.FakeAnnotatedElement
+ && ((ConstructorParameter.FakeAnnotatedElement) element).getParameterIndex() == 0
+ && type instanceof Class<?>
+ && ((Class<?>) type).isAssignableFrom(adaptable.getClass())) {
return adaptable;
}
}
@@ -62,7 +70,7 @@
}
@Override
- @SuppressWarnings({ "unused", "null" })
+ @SuppressWarnings({"unused", "null"})
public InjectAnnotationProcessor2 createAnnotationProcessor(AnnotatedElement element) {
// check if the element has the expected annotation
Self annotation = element.getAnnotation(Self.class);
@@ -91,5 +99,4 @@
return annotation.optional();
}
}
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/injectors/SlingObjectInjector.java b/src/main/java/org/apache/sling/models/impl/injectors/SlingObjectInjector.java
index f582ad8..dbd59b4 100644
--- a/src/main/java/org/apache/sling/models/impl/injectors/SlingObjectInjector.java
+++ b/src/main/java/org/apache/sling/models/impl/injectors/SlingObjectInjector.java
@@ -1,27 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.injectors;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Type;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Type;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
@@ -45,7 +47,9 @@
* Resource.
* Documentation see {@link SlingObject}.
*/
-@Component(property=Constants.SERVICE_RANKING+":Integer="+Integer.MAX_VALUE, service={Injector.class, StaticInjectAnnotationProcessorFactory.class, AcceptsNullName.class})
+@Component(
+ property = Constants.SERVICE_RANKING + ":Integer=" + Integer.MAX_VALUE,
+ service = {Injector.class, StaticInjectAnnotationProcessorFactory.class, AcceptsNullName.class})
public final class SlingObjectInjector implements Injector, StaticInjectAnnotationProcessorFactory, AcceptsNullName {
/**
@@ -59,7 +63,11 @@
}
@Override
- public Object getValue(final @NotNull Object adaptable, final String name, final @NotNull Type type, final @NotNull AnnotatedElement element,
+ public Object getValue(
+ final @NotNull Object adaptable,
+ final String name,
+ final @NotNull Type type,
+ final @NotNull AnnotatedElement element,
final @NotNull DisposalCallbackRegistry callbackRegistry) {
// only class types are supported
@@ -77,7 +85,8 @@
if (requestedClass.equals(Resource.class) && element.isAnnotationPresent(SlingObject.class)) {
return request.getResource();
}
- if (requestedClass.equals(SlingHttpServletRequest.class) || requestedClass.equals(HttpServletRequest.class)) {
+ if (requestedClass.equals(SlingHttpServletRequest.class)
+ || requestedClass.equals(HttpServletRequest.class)) {
return request;
}
if (requestedClass.equals(SlingHttpServletResponse.class)
@@ -122,7 +131,7 @@
}
@Override
- @SuppressWarnings({ "unused", "null" })
+ @SuppressWarnings({"unused", "null"})
public InjectAnnotationProcessor2 createAnnotationProcessor(final AnnotatedElement element) {
// check if the element has the expected annotation
SlingObject annotation = element.getAnnotation(SlingObject.class);
diff --git a/src/main/java/org/apache/sling/models/impl/injectors/ValueMapInjector.java b/src/main/java/org/apache/sling/models/impl/injectors/ValueMapInjector.java
index 1a36844..e70e6a7 100644
--- a/src/main/java/org/apache/sling/models/impl/injectors/ValueMapInjector.java
+++ b/src/main/java/org/apache/sling/models/impl/injectors/ValueMapInjector.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.injectors;
@@ -42,9 +44,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Component(property=Constants.SERVICE_RANKING+":Integer=2000", service={Injector.class, InjectAnnotationProcessorFactory.class, ValuePreparer.class})
+@Component(
+ property = Constants.SERVICE_RANKING + ":Integer=2000",
+ service = {Injector.class, InjectAnnotationProcessorFactory.class, ValuePreparer.class})
@SuppressWarnings("deprecation")
-public class ValueMapInjector extends AbstractInjector implements Injector, InjectAnnotationProcessorFactory, ValuePreparer {
+public class ValueMapInjector extends AbstractInjector
+ implements Injector, InjectAnnotationProcessorFactory, ValuePreparer {
private static final Logger log = LoggerFactory.getLogger(ValueMapInjector.class);
@@ -54,8 +59,12 @@
}
@Override
- @SuppressWarnings({ "unused", "null" })
- public Object getValue(@NotNull Object adaptable, String name, @NotNull Type type, @NotNull AnnotatedElement element,
+ @SuppressWarnings({"unused", "null"})
+ public Object getValue(
+ @NotNull Object adaptable,
+ String name,
+ @NotNull Type type,
+ @NotNull AnnotatedElement element,
@NotNull DisposalCallbackRegistry callbackRegistry) {
if (adaptable == ObjectUtils.NULL) {
return null;
@@ -74,7 +83,8 @@
if (componentType.isPrimitive()) {
Class<?> wrapper = ClassUtils.primitiveToWrapper(componentType);
if (wrapper != componentType) {
- Object wrapperArray = map.get(name, Array.newInstance(wrapper, 0).getClass());
+ Object wrapperArray =
+ map.get(name, Array.newInstance(wrapper, 0).getClass());
if (wrapperArray != null) {
return unwrapArray(wrapperArray, componentType);
}
@@ -82,7 +92,8 @@
} else {
Class<?> primitiveType = ClassUtils.wrapperToPrimitive(componentType);
if (primitiveType != componentType) {
- Object primitiveArray = map.get(name, Array.newInstance(primitiveType, 0).getClass());
+ Object primitiveArray = map.get(
+ name, Array.newInstance(primitiveType, 0).getClass());
if (primitiveArray != null) {
return wrapArray(primitiveArray, componentType);
}
@@ -106,7 +117,6 @@
Object array = map.get(name, Array.newInstance(itemType, 0).getClass());
if (array == null) {
return null;
-
}
return Arrays.asList((Object[]) array);
@@ -141,7 +151,7 @@
}
@Override
- @SuppressWarnings({ "unused", "null" })
+ @SuppressWarnings({"unused", "null"})
public InjectAnnotationProcessor createAnnotationProcessor(Object adaptable, AnnotatedElement element) {
// check if the element has the expected annotation
ValueMapValue annotation = element.getAnnotation(ValueMapValue.class);
diff --git a/src/main/java/org/apache/sling/models/impl/model/AbstractInjectableElement.java b/src/main/java/org/apache/sling/models/impl/model/AbstractInjectableElement.java
index 1ed8b53..21dbe5a 100644
--- a/src/main/java/org/apache/sling/models/impl/model/AbstractInjectableElement.java
+++ b/src/main/java/org/apache/sling/models/impl/model/AbstractInjectableElement.java
@@ -18,6 +18,8 @@
*/
package org.apache.sling.models.impl.model;
+import javax.inject.Named;
+
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Array;
import java.lang.reflect.ParameterizedType;
@@ -26,8 +28,6 @@
import java.util.Collection;
import java.util.List;
-import javax.inject.Named;
-
import org.apache.commons.lang3.ArrayUtils;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
@@ -63,8 +63,12 @@
private static final Logger log = LoggerFactory.getLogger(ModelAdapterFactory.class);
- public AbstractInjectableElement(AnnotatedElement element, Type type, String defaultName,
- StaticInjectAnnotationProcessorFactory[] processorFactories, DefaultInjectionStrategy defaultInjectionStrategy) {
+ public AbstractInjectableElement(
+ AnnotatedElement element,
+ Type type,
+ String defaultName,
+ StaticInjectAnnotationProcessorFactory[] processorFactories,
+ DefaultInjectionStrategy defaultInjectionStrategy) {
this.element = element;
this.type = type;
InjectAnnotationProcessor2 annotationProcessor = getAnnotationProcessor(element, processorFactories);
@@ -79,7 +83,8 @@
this.defaultInjectionStrategy = defaultInjectionStrategy;
}
- private static InjectAnnotationProcessor2 getAnnotationProcessor(AnnotatedElement element, StaticInjectAnnotationProcessorFactory[] processorFactories) {
+ private static InjectAnnotationProcessor2 getAnnotationProcessor(
+ AnnotatedElement element, StaticInjectAnnotationProcessorFactory[] processorFactories) {
for (StaticInjectAnnotationProcessorFactory processorFactory : processorFactories) {
InjectAnnotationProcessor2 annotationProcessor = processorFactory.createAnnotationProcessor(element);
if (annotationProcessor != null) {
@@ -90,7 +95,8 @@
}
@SuppressWarnings("unused")
- private static String getName(AnnotatedElement element, String defaultName, InjectAnnotationProcessor2 annotationProcessor) {
+ private static String getName(
+ AnnotatedElement element, String defaultName, InjectAnnotationProcessor2 annotationProcessor) {
String name = null;
if (annotationProcessor != null) {
name = annotationProcessor.getName();
@@ -99,8 +105,7 @@
Named namedAnnotation = element.getAnnotation(Named.class);
if (namedAnnotation != null) {
name = namedAnnotation.value();
- }
- else {
+ } else {
name = defaultName;
}
}
@@ -134,7 +139,8 @@
return spec;
}
- private static boolean getHasDefaultValue(AnnotatedElement element, InjectAnnotationProcessor2 annotationProcessor) {
+ private static boolean getHasDefaultValue(
+ AnnotatedElement element, InjectAnnotationProcessor2 annotationProcessor) {
if (annotationProcessor != null) {
return annotationProcessor.hasDefault();
}
@@ -142,7 +148,8 @@
}
@SuppressWarnings("unused")
- private static Object getDefaultValue(AnnotatedElement element, Type type, InjectAnnotationProcessor2 annotationProcessor) {
+ private static Object getDefaultValue(
+ AnnotatedElement element, Type type, InjectAnnotationProcessor2 annotationProcessor) {
if (annotationProcessor != null && annotationProcessor.hasDefault()) {
return annotationProcessor.getDefault();
}
@@ -155,7 +162,7 @@
Object value = null;
if (type instanceof ParameterizedType) {
- ParameterizedType parameterizedType = (ParameterizedType)type;
+ ParameterizedType parameterizedType = (ParameterizedType) type;
Type rawType = parameterizedType.getRawType();
if ((rawType == Collection.class || rawType == List.class)
&& parameterizedType.getActualTypeArguments().length > 0) {
@@ -177,12 +184,10 @@
} else {
log.warn("Default values for {} List/Collection are not supported (used on {})", itemType, element);
}
- }
- else {
+ } else {
log.warn("Cannot provide default for {} (used on {})", type, element);
}
- }
- else if (type instanceof Class) {
+ } else if (type instanceof Class) {
Class<?> injectedClass = (Class<?>) type;
if (injectedClass.isArray()) {
Class<?> componentType = injectedClass.getComponentType();
@@ -217,19 +222,33 @@
}
} else {
if (injectedClass == String.class) {
- value = defaultAnnotation.values().length == 0 ? "" : defaultAnnotation.values()[0];
+ value = defaultAnnotation.values().length == 0
+ ? ""
+ : defaultAnnotation.values()[0];
} else if (injectedClass == Integer.class) {
- value = defaultAnnotation.intValues().length == 0 ? 0 : defaultAnnotation.intValues()[0];
+ value = defaultAnnotation.intValues().length == 0
+ ? 0
+ : defaultAnnotation.intValues()[0];
} else if (injectedClass == Long.class) {
- value = defaultAnnotation.longValues().length == 0 ? 0l : defaultAnnotation.longValues()[0];
+ value = defaultAnnotation.longValues().length == 0
+ ? 0l
+ : defaultAnnotation.longValues()[0];
} else if (injectedClass == Boolean.class) {
- value = defaultAnnotation.booleanValues().length == 0 ? false : defaultAnnotation.booleanValues()[0];
+ value = defaultAnnotation.booleanValues().length == 0
+ ? false
+ : defaultAnnotation.booleanValues()[0];
} else if (injectedClass == Short.class) {
- value = defaultAnnotation.shortValues().length == 0 ? ((short) 0) : defaultAnnotation.shortValues()[0];
+ value = defaultAnnotation.shortValues().length == 0
+ ? ((short) 0)
+ : defaultAnnotation.shortValues()[0];
} else if (injectedClass == Float.class) {
- value = defaultAnnotation.floatValues().length == 0 ? 0f : defaultAnnotation.floatValues()[0];
+ value = defaultAnnotation.floatValues().length == 0
+ ? 0f
+ : defaultAnnotation.floatValues()[0];
} else if (injectedClass == Double.class) {
- value = defaultAnnotation.doubleValues().length == 0 ? 0d : defaultAnnotation.doubleValues()[0];
+ value = defaultAnnotation.doubleValues().length == 0
+ ? 0d
+ : defaultAnnotation.doubleValues()[0];
} else {
log.warn("Default values for {} are not supported (used on {})", injectedClass, element);
}
@@ -252,12 +271,11 @@
int arrayLength = Array.getLength(array);
if (arrayLength > 0) {
List<T> result = new ArrayList<>();
- for (int i=0; i<arrayLength; i++) {
- result.add((T)Array.get(array, i));
+ for (int i = 0; i < arrayLength; i++) {
+ result.add((T) Array.get(array, i));
}
return result;
}
-
}
return null;
}
@@ -281,10 +299,13 @@
return element.isAnnotationPresent(Required.class);
}
- private static DefaultInjectionStrategy getInjectionStrategy(AnnotatedElement element, InjectAnnotationProcessor annotationProcessor, DefaultInjectionStrategy defaultInjectionStrategy) {
+ private static DefaultInjectionStrategy getInjectionStrategy(
+ AnnotatedElement element,
+ InjectAnnotationProcessor annotationProcessor,
+ DefaultInjectionStrategy defaultInjectionStrategy) {
if (annotationProcessor != null) {
if (annotationProcessor instanceof InjectAnnotationProcessor2) {
- switch (((InjectAnnotationProcessor2)annotationProcessor).getInjectionStrategy()) {
+ switch (((InjectAnnotationProcessor2) annotationProcessor).getInjectionStrategy()) {
case OPTIONAL:
return DefaultInjectionStrategy.OPTIONAL;
case REQUIRED:
@@ -323,7 +344,9 @@
}
@Override
- public Class<? extends ViaProviderType> getViaProviderType() { return this.via.type; }
+ public Class<? extends ViaProviderType> getViaProviderType() {
+ return this.via.type;
+ }
@Override
public boolean hasDefaultValue() {
@@ -358,5 +381,4 @@
String via;
Class<? extends ViaProviderType> type;
}
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/model/ConstructorParameter.java b/src/main/java/org/apache/sling/models/impl/model/ConstructorParameter.java
index 2eb525c..5394dbd 100644
--- a/src/main/java/org/apache/sling/models/impl/model/ConstructorParameter.java
+++ b/src/main/java/org/apache/sling/models/impl/model/ConstructorParameter.java
@@ -38,9 +38,20 @@
private final boolean isPrimitive;
private final int parameterIndex;
- public ConstructorParameter(Annotation[] annotations, Type parameterType, Type genericType, boolean isPrimitive,
- int parameterIndex, StaticInjectAnnotationProcessorFactory[] processorFactories, DefaultInjectionStrategy defaultInjectionStrategy) {
- super(new FakeAnnotatedElement(annotations, parameterIndex), genericType, null, processorFactories, defaultInjectionStrategy);
+ public ConstructorParameter(
+ Annotation[] annotations,
+ Type parameterType,
+ Type genericType,
+ boolean isPrimitive,
+ int parameterIndex,
+ StaticInjectAnnotationProcessorFactory[] processorFactories,
+ DefaultInjectionStrategy defaultInjectionStrategy) {
+ super(
+ new FakeAnnotatedElement(annotations, parameterIndex),
+ genericType,
+ null,
+ processorFactories,
+ defaultInjectionStrategy);
this.parameterType = parameterType;
this.genericType = genericType;
this.isPrimitive = isPrimitive;
@@ -83,12 +94,12 @@
return getAnnotation(paramClass) != null;
}
- @SuppressWarnings({ "unchecked", "null" })
+ @SuppressWarnings({"unchecked", "null"})
@Override
public <T extends Annotation> T getAnnotation(Class<T> paramClass) {
for (Annotation annotation : this.annotations) {
if (paramClass.isInstance(annotation)) {
- return (T)annotation;
+ return (T) annotation;
}
}
return null;
@@ -113,7 +124,5 @@
return "FakeAnnotatedElement [annotations=" + Arrays.toString(annotations) + ", parameterIndex="
+ parameterIndex + "]";
}
-
}
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/model/InjectableElement.java b/src/main/java/org/apache/sling/models/impl/model/InjectableElement.java
index 105b826..6ff7489 100644
--- a/src/main/java/org/apache/sling/models/impl/model/InjectableElement.java
+++ b/src/main/java/org/apache/sling/models/impl/model/InjectableElement.java
@@ -74,5 +74,4 @@
* @return {@code true} if the element is optional otherwise {@code false}
*/
boolean isOptional(InjectAnnotationProcessor annotationProcessor);
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/model/InjectableField.java b/src/main/java/org/apache/sling/models/impl/model/InjectableField.java
index 10a70e1..56f5081 100644
--- a/src/main/java/org/apache/sling/models/impl/model/InjectableField.java
+++ b/src/main/java/org/apache/sling/models/impl/model/InjectableField.java
@@ -28,11 +28,19 @@
import org.apache.sling.models.spi.injectorspecific.StaticInjectAnnotationProcessorFactory;
public class InjectableField extends AbstractInjectableElement {
-
+
private final Field field;
-
- public InjectableField(Field field, StaticInjectAnnotationProcessorFactory[] processorFactories, DefaultInjectionStrategy defaultInjectionStrategy) {
- super(field, ReflectionUtil.mapPrimitiveClasses(field.getGenericType()), field.getName(), processorFactories, defaultInjectionStrategy);
+
+ public InjectableField(
+ Field field,
+ StaticInjectAnnotationProcessorFactory[] processorFactories,
+ DefaultInjectionStrategy defaultInjectionStrategy) {
+ super(
+ field,
+ ReflectionUtil.mapPrimitiveClasses(field.getGenericType()),
+ field.getName(),
+ processorFactories,
+ defaultInjectionStrategy);
this.field = field;
}
diff --git a/src/main/java/org/apache/sling/models/impl/model/InjectableMethod.java b/src/main/java/org/apache/sling/models/impl/model/InjectableMethod.java
index b0d954b..04437a0 100644
--- a/src/main/java/org/apache/sling/models/impl/model/InjectableMethod.java
+++ b/src/main/java/org/apache/sling/models/impl/model/InjectableMethod.java
@@ -26,12 +26,20 @@
import org.apache.sling.models.spi.injectorspecific.StaticInjectAnnotationProcessorFactory;
public class InjectableMethod extends AbstractInjectableElement {
-
+
private final Method method;
private final Type genericReturnType;
- public InjectableMethod(Method method, StaticInjectAnnotationProcessorFactory[] processorFactories, DefaultInjectionStrategy defaultInjectionStrategy) {
- super(method, ReflectionUtil.mapPrimitiveClasses(method.getGenericReturnType()), getDefaultName(method), processorFactories, defaultInjectionStrategy);
+ public InjectableMethod(
+ Method method,
+ StaticInjectAnnotationProcessorFactory[] processorFactories,
+ DefaultInjectionStrategy defaultInjectionStrategy) {
+ super(
+ method,
+ ReflectionUtil.mapPrimitiveClasses(method.getGenericReturnType()),
+ getDefaultName(method),
+ processorFactories,
+ defaultInjectionStrategy);
this.method = method;
this.genericReturnType = method.getGenericReturnType();
}
@@ -61,5 +69,4 @@
return methodName;
}
}
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/model/ModelClass.java b/src/main/java/org/apache/sling/models/impl/model/ModelClass.java
index 4f81a62..2e35892 100644
--- a/src/main/java/org/apache/sling/models/impl/model/ModelClass.java
+++ b/src/main/java/org/apache/sling/models/impl/model/ModelClass.java
@@ -48,7 +48,7 @@
}
updateProcessorFactories(processorFactories);
}
-
+
/**
* Updates processor factories after the model class was instantiated.
* @param processorFactories Static injector annotation processor factories
@@ -58,43 +58,53 @@
this.injectableFields = getInjectableFields(type, processorFactories, defaultInjectionStrategy);
this.injectableMethods = getInjectableMethods(type, processorFactories, defaultInjectionStrategy);
}
-
+
@SuppressWarnings("unchecked")
- private static <T> ModelClassConstructor<T>[] getConstructors(Class<T> type, StaticInjectAnnotationProcessorFactory[] processorFactories, DefaultInjectionStrategy defaultInjectionStrategy) {
+ private static <T> ModelClassConstructor<T>[] getConstructors(
+ Class<T> type,
+ StaticInjectAnnotationProcessorFactory[] processorFactories,
+ DefaultInjectionStrategy defaultInjectionStrategy) {
if (type.isInterface()) {
return new ModelClassConstructor[0];
}
Constructor<T>[] constructors = (Constructor<T>[]) type.getDeclaredConstructors();
-
- // sort the constructor list in order from most params to least params, and constructors with @Inject annotation first
+
+ // sort the constructor list in order from most params to least params, and constructors with @Inject annotation
+ // first
Arrays.sort(constructors, new ParameterCountInjectComparator());
ModelClassConstructor<T>[] array = new ModelClassConstructor[constructors.length];
- for (int i=0; i<array.length; i++) {
+ for (int i = 0; i < array.length; i++) {
array[i] = new ModelClassConstructor<>(constructors[i], processorFactories, defaultInjectionStrategy);
}
return array;
}
- private static InjectableField[] getInjectableFields(Class<?> type, StaticInjectAnnotationProcessorFactory[] processorFactories, DefaultInjectionStrategy defaultInjectionStrategy) {
+ private static InjectableField[] getInjectableFields(
+ Class<?> type,
+ StaticInjectAnnotationProcessorFactory[] processorFactories,
+ DefaultInjectionStrategy defaultInjectionStrategy) {
if (type.isInterface()) {
return new InjectableField[0];
}
List<Field> injectableFields = ReflectionUtil.collectInjectableFields(type);
InjectableField[] array = new InjectableField[injectableFields.size()];
- for (int i=0; i<array.length; i++) {
+ for (int i = 0; i < array.length; i++) {
array[i] = new InjectableField(injectableFields.get(i), processorFactories, defaultInjectionStrategy);
}
return array;
}
- private static InjectableMethod[] getInjectableMethods(Class<?> type, StaticInjectAnnotationProcessorFactory[] processorFactories, DefaultInjectionStrategy defaultInjectionStrategy) {
+ private static InjectableMethod[] getInjectableMethods(
+ Class<?> type,
+ StaticInjectAnnotationProcessorFactory[] processorFactories,
+ DefaultInjectionStrategy defaultInjectionStrategy) {
if (!type.isInterface()) {
return new InjectableMethod[0];
}
List<Method> injectableMethods = ReflectionUtil.collectInjectableMethods(type);
InjectableMethod[] array = new InjectableMethod[injectableMethods.size()];
- for (int i=0; i<array.length; i++) {
+ for (int i = 0; i < array.length; i++) {
array[i] = new InjectableMethod(injectableMethods.get(i), processorFactories, defaultInjectionStrategy);
}
return array;
@@ -103,15 +113,15 @@
public Class<ModelType> getType() {
return this.type;
}
-
+
public Model getModelAnnotation() {
return this.modelAnnotation;
}
-
+
public boolean hasModelAnnotation() {
return this.modelAnnotation != null;
}
-
+
public ModelClassConstructor<ModelType>[] getConstructors() {
return constructors;
}
@@ -123,5 +133,4 @@
public InjectableMethod[] getInjectableMethods() {
return this.injectableMethods;
}
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/model/ModelClassConstructor.java b/src/main/java/org/apache/sling/models/impl/model/ModelClassConstructor.java
index 23460be..ffcdfca 100644
--- a/src/main/java/org/apache/sling/models/impl/model/ModelClassConstructor.java
+++ b/src/main/java/org/apache/sling/models/impl/model/ModelClassConstructor.java
@@ -18,12 +18,12 @@
*/
package org.apache.sling.models.impl.model;
+import javax.inject.Inject;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
-import javax.inject.Inject;
-
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.impl.ReflectionUtil;
import org.apache.sling.models.spi.injectorspecific.StaticInjectAnnotationProcessorFactory;
@@ -34,7 +34,10 @@
private final boolean hasInjectAnnotation;
private final ConstructorParameter[] constructorParametersArray;
- public ModelClassConstructor(Constructor<M> constructor, StaticInjectAnnotationProcessorFactory[] processorFactories, DefaultInjectionStrategy defaultInjectionStrategy) {
+ public ModelClassConstructor(
+ Constructor<M> constructor,
+ StaticInjectAnnotationProcessorFactory[] processorFactories,
+ DefaultInjectionStrategy defaultInjectionStrategy) {
this.constructor = constructor;
this.hasInjectAnnotation = constructor.isAnnotationPresent(Inject.class);
@@ -45,29 +48,35 @@
Type genericType = ReflectionUtil.mapPrimitiveClasses(parameterTypes[i]);
boolean isPrimitive = (parameterTypes[i] != genericType);
this.constructorParametersArray[i] = new ConstructorParameter(
- constructor.getParameterAnnotations()[i], constructor.getParameterTypes()[i], genericType, isPrimitive, i,
- processorFactories, defaultInjectionStrategy);
+ constructor.getParameterAnnotations()[i],
+ constructor.getParameterTypes()[i],
+ genericType,
+ isPrimitive,
+ i,
+ processorFactories,
+ defaultInjectionStrategy);
}
}
/**
* Proxies the call to {@link Constructor#newInstance(Object...)}, checking (and
* setting) accessibility first.
- *
+ *
* @param parameters
* the constructor parameters that are passed to
* {@link Constructor#newInstance(Object...)}
* @return The constructed object
- *
+ *
* @throws InstantiationException when {@link Constructor#newInstance(Object...)} would throw
* @throws IllegalAccessException when {@link Constructor#newInstance(Object...)} would throw
* @throws IllegalArgumentException when {@link Constructor#newInstance(Object...)} would throw
* @throws InvocationTargetException when {@link Constructor#newInstance(Object...)} would throw
- *
+ *
* @see Constructor#newInstance(Object...)
*/
- @SuppressWarnings({"java:S3011","java:S1874"})
- public M newInstance(Object... parameters) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ @SuppressWarnings({"java:S3011", "java:S1874"})
+ public M newInstance(Object... parameters)
+ throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
constructor.setAccessible(true);
return constructor.newInstance(parameters);
}
@@ -82,6 +91,6 @@
public ConstructorParameter[] getConstructorParameters() {
return constructorParametersArray;
- };
-
+ }
+ ;
}
diff --git a/src/main/java/org/apache/sling/models/impl/model/OptionalTypedInjectableElement.java b/src/main/java/org/apache/sling/models/impl/model/OptionalTypedInjectableElement.java
index ba4f160..8a50bfb 100644
--- a/src/main/java/org/apache/sling/models/impl/model/OptionalTypedInjectableElement.java
+++ b/src/main/java/org/apache/sling/models/impl/model/OptionalTypedInjectableElement.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.model;
@@ -75,7 +77,8 @@
@Override
public Object getDefaultValue() {
- // Default value injector will be evaluated last, make sure we return a value here so the injection is successful
+ // Default value injector will be evaluated last, make sure we return a value here so the injection is
+ // successful
return element.getDefaultValue() == null ? Optional.empty() : element.getDefaultValue();
}
diff --git a/src/main/java/org/apache/sling/models/impl/model/ParameterCountInjectComparator.java b/src/main/java/org/apache/sling/models/impl/model/ParameterCountInjectComparator.java
index b75caf6..2618828 100644
--- a/src/main/java/org/apache/sling/models/impl/model/ParameterCountInjectComparator.java
+++ b/src/main/java/org/apache/sling/models/impl/model/ParameterCountInjectComparator.java
@@ -18,11 +18,11 @@
*/
package org.apache.sling.models.impl.model;
+import javax.inject.Inject;
+
import java.lang.reflect.Constructor;
import java.util.Comparator;
-import javax.inject.Inject;
-
/**
* Comparator which sorts constructors by the number of parameters
* in reverse order (most params to least params).
@@ -34,10 +34,9 @@
@Override
public int compare(Constructor<?> o1, Constructor<?> o2) {
int result = compareParameterCount(o2.getParameterTypes().length, o1.getParameterTypes().length);
- if (result==0) {
+ if (result == 0) {
return compareInjectAnnotation(o1, o2);
- }
- else {
+ } else {
return result;
}
}
@@ -51,13 +50,10 @@
boolean hasInject2 = o2.isAnnotationPresent(Inject.class);
if (hasInject1 && !hasInject2) {
return -1;
- }
- else if (hasInject2 && !hasInject1) {
+ } else if (hasInject2 && !hasInject1) {
return 1;
- }
- else {
+ } else {
return 0;
}
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/models/impl/via/AbstractResourceTypeViaProvider.java b/src/main/java/org/apache/sling/models/impl/via/AbstractResourceTypeViaProvider.java
index ecacb3d..b6094a4 100644
--- a/src/main/java/org/apache/sling/models/impl/via/AbstractResourceTypeViaProvider.java
+++ b/src/main/java/org/apache/sling/models/impl/via/AbstractResourceTypeViaProvider.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.via;
@@ -33,7 +35,7 @@
if (!handle(value)) {
return ORIGINAL;
}
- if (original instanceof Resource) {
+ if (original instanceof Resource) {
final Resource resource = (Resource) original;
final String resourceType = getResourceType(resource, value);
if (resourceType == null) {
@@ -41,7 +43,7 @@
return null;
}
return new ResourceTypeForcingResourceWrapper(resource, resourceType);
- } else if (original instanceof SlingHttpServletRequest) {
+ } else if (original instanceof SlingHttpServletRequest) {
final SlingHttpServletRequest request = (SlingHttpServletRequest) original;
final Resource resource = request.getResource();
if (resource == null) {
@@ -53,14 +55,15 @@
return null;
}
return new ResourceTypeForcingRequestWrapper(request, resource, resourceType);
- } else {
- log.warn("Received unexpected adaptable of type {}.", original.getClass().getName());
+ } else {
+ log.warn(
+ "Received unexpected adaptable of type {}.",
+ original.getClass().getName());
return null;
- }
+ }
}
protected abstract boolean handle(@NotNull String value);
protected abstract @Nullable String getResourceType(@NotNull Resource resource, @NotNull String value);
-
}
diff --git a/src/main/java/org/apache/sling/models/impl/via/BeanPropertyViaProvider.java b/src/main/java/org/apache/sling/models/impl/via/BeanPropertyViaProvider.java
index 3051fa1..f383822 100644
--- a/src/main/java/org/apache/sling/models/impl/via/BeanPropertyViaProvider.java
+++ b/src/main/java/org/apache/sling/models/impl/via/BeanPropertyViaProvider.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.via;
@@ -28,7 +30,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Component(service=ViaProvider.class)
+@Component(service = ViaProvider.class)
public class BeanPropertyViaProvider implements ViaProvider {
private static final Logger log = LoggerFactory.getLogger(BeanPropertyViaProvider.class);
diff --git a/src/main/java/org/apache/sling/models/impl/via/ChildResourceViaProvider.java b/src/main/java/org/apache/sling/models/impl/via/ChildResourceViaProvider.java
index 6ccc9a4..128a06c 100644
--- a/src/main/java/org/apache/sling/models/impl/via/ChildResourceViaProvider.java
+++ b/src/main/java/org/apache/sling/models/impl/via/ChildResourceViaProvider.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.via;
@@ -27,7 +29,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Component(service=ViaProvider.class)
+@Component(service = ViaProvider.class)
public class ChildResourceViaProvider implements ViaProvider {
private static final Logger log = LoggerFactory.getLogger(ChildResourceViaProvider.class);
@@ -57,7 +59,9 @@
}
return new ChildResourceRequestWrapper(request, child);
} else {
- log.warn("Received unexpected adaptable of type {}.", original.getClass().getName());
+ log.warn(
+ "Received unexpected adaptable of type {}.",
+ original.getClass().getName());
return null;
}
}
diff --git a/src/main/java/org/apache/sling/models/impl/via/ForcedResourceTypeViaProvider.java b/src/main/java/org/apache/sling/models/impl/via/ForcedResourceTypeViaProvider.java
index d6c29ec..55d30e6 100644
--- a/src/main/java/org/apache/sling/models/impl/via/ForcedResourceTypeViaProvider.java
+++ b/src/main/java/org/apache/sling/models/impl/via/ForcedResourceTypeViaProvider.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.via;
@@ -24,7 +26,7 @@
import org.jetbrains.annotations.NotNull;
import org.osgi.service.component.annotations.Component;
-@Component(service=ViaProvider.class)
+@Component(service = ViaProvider.class)
public class ForcedResourceTypeViaProvider extends AbstractResourceTypeViaProvider {
@Override
public Class<? extends ViaProviderType> getType() {
diff --git a/src/main/java/org/apache/sling/models/impl/via/OriginalResourceTypeViaProvider.java b/src/main/java/org/apache/sling/models/impl/via/OriginalResourceTypeViaProvider.java
index 00ef495..9344da6 100644
--- a/src/main/java/org/apache/sling/models/impl/via/OriginalResourceTypeViaProvider.java
+++ b/src/main/java/org/apache/sling/models/impl/via/OriginalResourceTypeViaProvider.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.via;
diff --git a/src/main/java/org/apache/sling/models/impl/via/ResourceSuperTypeViaProvider.java b/src/main/java/org/apache/sling/models/impl/via/ResourceSuperTypeViaProvider.java
index 2ed229b..b6fc4f4 100644
--- a/src/main/java/org/apache/sling/models/impl/via/ResourceSuperTypeViaProvider.java
+++ b/src/main/java/org/apache/sling/models/impl/via/ResourceSuperTypeViaProvider.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.via;
@@ -23,7 +25,7 @@
import org.jetbrains.annotations.NotNull;
import org.osgi.service.component.annotations.Component;
-@Component(service=ViaProvider.class)
+@Component(service = ViaProvider.class)
public class ResourceSuperTypeViaProvider extends AbstractResourceTypeViaProvider {
@Override
diff --git a/src/main/java/org/apache/sling/models/impl/via/ResourceTypeForcingRequestWrapper.java b/src/main/java/org/apache/sling/models/impl/via/ResourceTypeForcingRequestWrapper.java
index 9a57490..35e2e29 100644
--- a/src/main/java/org/apache/sling/models/impl/via/ResourceTypeForcingRequestWrapper.java
+++ b/src/main/java/org/apache/sling/models/impl/via/ResourceTypeForcingRequestWrapper.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.via;
diff --git a/src/main/java/org/apache/sling/models/impl/via/ResourceTypeForcingResourceWrapper.java b/src/main/java/org/apache/sling/models/impl/via/ResourceTypeForcingResourceWrapper.java
index beff897..1227ef0 100644
--- a/src/main/java/org/apache/sling/models/impl/via/ResourceTypeForcingResourceWrapper.java
+++ b/src/main/java/org/apache/sling/models/impl/via/ResourceTypeForcingResourceWrapper.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.via;
diff --git a/src/test/java/org/apache/sling/models/impl/AdapterFactoryTest.java b/src/test/java/org/apache/sling/models/impl/AdapterFactoryTest.java
index 8b20b31..314dd3d 100644
--- a/src/test/java/org/apache/sling/models/impl/AdapterFactoryTest.java
+++ b/src/test/java/org/apache/sling/models/impl/AdapterFactoryTest.java
@@ -1,24 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -57,6 +56,9 @@
import org.osgi.util.converter.Converter;
import org.osgi.util.converter.Converters;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class AdapterFactoryTest {
@@ -92,8 +94,16 @@
factory = createModelAdapterFactory();
factory.bindInjector(new ValueMapInjector(), new ServicePropertiesMap(0, 0));
factory.bindInjector(new SelfInjector(), new ServicePropertiesMap(1, 1));
- factory.modelExporters = Arrays.<ModelExporter>asList(new FirstStringExporter(), new SecondStringExporter(), new FirstIntegerExporter());
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(DefaultStringModel.class, ConstructorWithExceptionModel.class, NestedModel.class, NestedModelWithInvalidAdaptable.class, NestedModelWithInvalidAdaptable2.class, ResourceModelWithRequiredField.class, CachedModelWithSelfReference.class) ;
+ factory.modelExporters = Arrays.<ModelExporter>asList(
+ new FirstStringExporter(), new SecondStringExporter(), new FirstIntegerExporter());
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ DefaultStringModel.class,
+ ConstructorWithExceptionModel.class,
+ NestedModel.class,
+ NestedModelWithInvalidAdaptable.class,
+ NestedModelWithInvalidAdaptable2.class,
+ ResourceModelWithRequiredField.class,
+ CachedModelWithSelfReference.class);
}
@Test
@@ -176,7 +186,7 @@
Assert.assertEquals("required", model.getNestedModel().getRequired());
}
- @Test(expected=MissingElementsException.class)
+ @Test(expected = MissingElementsException.class)
public void testCreatedNestedModelWithMissingElements() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("invalid", "required");
@@ -193,7 +203,8 @@
when(result.wasSuccessful()).thenReturn(true);
when(result.getValue()).thenReturn(new Object());
- String exported = factory.handleAndExportResult(result, "second", String.class, Collections.<String, String>emptyMap());
+ String exported =
+ factory.handleAndExportResult(result, "second", String.class, Collections.<String, String>emptyMap());
Assert.assertEquals("Export from second", exported);
}
@@ -204,7 +215,8 @@
when(result.wasSuccessful()).thenReturn(true);
when(result.getValue()).thenReturn(new Object());
- Integer exported = factory.handleAndExportResult(result, "first", Integer.class, Collections.<String, String>emptyMap());
+ Integer exported =
+ factory.handleAndExportResult(result, "first", Integer.class, Collections.<String, String>emptyMap());
Assert.assertEquals(Integer.valueOf(42), exported);
}
@@ -227,7 +239,8 @@
@Nullable
@Override
@SuppressWarnings("unchecked")
- public <T> T export(@NotNull Object o, @NotNull Class<T> aClass, @NotNull Map<String, String> map) throws ExportException {
+ public <T> T export(@NotNull Object o, @NotNull Class<T> aClass, @NotNull Map<String, String> map)
+ throws ExportException {
if (aClass == String.class) {
return (T) "Export from first";
} else {
@@ -251,7 +264,8 @@
@Nullable
@Override
- public <T> T export(@NotNull Object o, @NotNull Class<T> aClass, @NotNull Map<String, String> map) throws ExportException {
+ public <T> T export(@NotNull Object o, @NotNull Class<T> aClass, @NotNull Map<String, String> map)
+ throws ExportException {
if (aClass == String.class) {
return (T) "Export from second";
} else {
@@ -275,7 +289,8 @@
@Nullable
@Override
- public <T> T export(@NotNull Object o, @NotNull Class<T> aClass, @NotNull Map<String, String> map) throws ExportException {
+ public <T> T export(@NotNull Object o, @NotNull Class<T> aClass, @NotNull Map<String, String> map)
+ throws ExportException {
if (aClass == Integer.class) {
return (T) Integer.valueOf(42);
} else {
diff --git a/src/test/java/org/apache/sling/models/impl/AdapterImplementationsTest.java b/src/test/java/org/apache/sling/models/impl/AdapterImplementationsTest.java
index ddb5071..093f52d 100644
--- a/src/test/java/org/apache/sling/models/impl/AdapterImplementationsTest.java
+++ b/src/test/java/org/apache/sling/models/impl/AdapterImplementationsTest.java
@@ -18,11 +18,6 @@
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.lenient;
-import static org.mockito.Mockito.when;
-
import java.util.Arrays;
import org.apache.sling.api.SlingHttpServletRequest;
@@ -38,6 +33,11 @@
import org.mockito.junit.MockitoJUnitRunner;
import org.osgi.framework.BundleContext;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class AdapterImplementationsTest {
@@ -61,9 +61,7 @@
@Before
public void setUp() {
underTest = new AdapterImplementations();
- underTest.setImplementationPickers(Arrays.asList(new ImplementationPicker[] {
- new FirstImplementationPicker()
- }));
+ underTest.setImplementationPickers(Arrays.asList(new ImplementationPicker[] {new FirstImplementationPicker()}));
}
@Test
@@ -78,7 +76,8 @@
public void testSingleMapping() {
underTest.addAll(String.class, SAMPLE_ADAPTER);
- assertEquals(String.class, underTest.lookup(SAMPLE_ADAPTER, SAMPLE_ADAPTABLE).getType());
+ assertEquals(
+ String.class, underTest.lookup(SAMPLE_ADAPTER, SAMPLE_ADAPTABLE).getType());
underTest.remove(SAMPLE_ADAPTER.getName(), String.class.getName());
@@ -91,11 +90,14 @@
underTest.addAll(Integer.class, SAMPLE_ADAPTER);
underTest.addAll(Long.class, SAMPLE_ADAPTER);
- assertEquals(Integer.class, underTest.lookup(SAMPLE_ADAPTER, SAMPLE_ADAPTABLE).getType());
+ assertEquals(
+ Integer.class,
+ underTest.lookup(SAMPLE_ADAPTER, SAMPLE_ADAPTABLE).getType());
underTest.remove(SAMPLE_ADAPTER.getName(), Integer.class.getName());
- assertEquals(Long.class, underTest.lookup(SAMPLE_ADAPTER, SAMPLE_ADAPTABLE).getType());
+ assertEquals(
+ Long.class, underTest.lookup(SAMPLE_ADAPTER, SAMPLE_ADAPTABLE).getType());
underTest.remove(SAMPLE_ADAPTER.getName(), Long.class.getName());
underTest.remove(SAMPLE_ADAPTER.getName(), String.class.getName());
@@ -117,23 +119,23 @@
@Test
public void testMultipleImplementationPickers() {
underTest.setImplementationPickers(Arrays.asList(
- new NoneImplementationPicker(),
- new LastImplementationPicker(),
- new FirstImplementationPicker()
- ));
+ new NoneImplementationPicker(), new LastImplementationPicker(), new FirstImplementationPicker()));
underTest.addAll(String.class, SAMPLE_ADAPTER);
underTest.addAll(Integer.class, SAMPLE_ADAPTER);
underTest.addAll(Long.class, SAMPLE_ADAPTER);
- assertEquals(String.class, underTest.lookup(SAMPLE_ADAPTER, SAMPLE_ADAPTABLE).getType());
+ assertEquals(
+ String.class, underTest.lookup(SAMPLE_ADAPTER, SAMPLE_ADAPTABLE).getType());
}
@Test
public void testSimpleModel() {
underTest.addAll(SAMPLE_ADAPTER, SAMPLE_ADAPTER);
- assertEquals(SAMPLE_ADAPTER, underTest.lookup(SAMPLE_ADAPTER, SAMPLE_ADAPTABLE).getType());
+ assertEquals(
+ SAMPLE_ADAPTER,
+ underTest.lookup(SAMPLE_ADAPTER, SAMPLE_ADAPTABLE).getType());
}
@Test
@@ -144,7 +146,7 @@
when(childResource.getResourceResolver()).thenReturn(resourceResolver);
when(resourceResolver.getParentResourceType(resource)).thenReturn(null);
when(resourceResolver.getParentResourceType(childResource)).thenReturn("sling/rt/one");
- when(resourceResolver.getSearchPath()).thenReturn(new String[] { "/apps/", "/libs/" });
+ when(resourceResolver.getSearchPath()).thenReturn(new String[] {"/apps/", "/libs/"});
// ensure we don't have any registrations for 'sling/rt/one'
assertNull(underTest.getModelClassForResource(resource));
@@ -158,7 +160,8 @@
// ensure that trying to reregister the resource type is a no-op
BundleContext secondBundleContext = MockOsgi.newBundleContext();
- underTest.registerModelToResourceType(secondBundleContext.getBundle(), "sling/rt/one", Resource.class, Integer.class);
+ underTest.registerModelToResourceType(
+ secondBundleContext.getBundle(), "sling/rt/one", Resource.class, Integer.class);
assertEquals(String.class, underTest.getModelClassForResource(resource));
assertEquals(String.class, underTest.getModelClassForResource(childResource));
@@ -175,7 +178,7 @@
when(childResource.getResourceResolver()).thenReturn(resourceResolver);
when(resourceResolver.getParentResourceType(resource)).thenReturn(null);
when(resourceResolver.getParentResourceType(childResource)).thenReturn("sling/rt/one");
- when(resourceResolver.getSearchPath()).thenReturn(new String[] { "/apps/", "/libs/" });
+ when(resourceResolver.getSearchPath()).thenReturn(new String[] {"/apps/", "/libs/"});
// ensure we don't have any registrations for 'sling/rt/one'
assertNull(underTest.getModelClassForResource(resource));
@@ -183,7 +186,8 @@
// now add a mapping for Resource -> String
BundleContext bundleContext = MockOsgi.newBundleContext();
- underTest.registerModelToResourceType(bundleContext.getBundle(), "/apps/sling/rt/one", Resource.class, String.class);
+ underTest.registerModelToResourceType(
+ bundleContext.getBundle(), "/apps/sling/rt/one", Resource.class, String.class);
assertEquals(String.class, underTest.getModelClassForResource(resource));
assertEquals(String.class, underTest.getModelClassForResource(childResource));
@@ -200,7 +204,7 @@
when(childResource.getResourceResolver()).thenReturn(resourceResolver);
when(resourceResolver.getParentResourceType(resource)).thenReturn(null);
when(resourceResolver.getParentResourceType(childResource)).thenReturn("/apps/sling/rt/one");
- when(resourceResolver.getSearchPath()).thenReturn(new String[] { "/apps/", "/libs/" });
+ when(resourceResolver.getSearchPath()).thenReturn(new String[] {"/apps/", "/libs/"});
// ensure we don't have any registrations for 'sling/rt/one'
assertNull(underTest.getModelClassForResource(resource));
@@ -222,7 +226,7 @@
when(resource.getResourceType()).thenReturn("sling/rt/one");
when(resource.getResourceResolver()).thenReturn(resourceResolver);
when(resourceResolver.getParentResourceType(resource)).thenReturn(null);
- when(resourceResolver.getSearchPath()).thenReturn(new String[] { "/apps/", "/libs/" });
+ when(resourceResolver.getSearchPath()).thenReturn(new String[] {"/apps/", "/libs/"});
when(request.getResource()).thenReturn(resource);
// ensure we don't have any registrations for 'sling/rt/one'
@@ -231,14 +235,16 @@
// now add a mapping for SlingHttpServletRequest -> String
BundleContext bundleContext = MockOsgi.newBundleContext();
- underTest.registerModelToResourceType(bundleContext.getBundle(), "sling/rt/one", SlingHttpServletRequest.class, String.class);
+ underTest.registerModelToResourceType(
+ bundleContext.getBundle(), "sling/rt/one", SlingHttpServletRequest.class, String.class);
underTest.registerModelToResourceType(bundleContext.getBundle(), "sling/rt/one", Resource.class, Integer.class);
assertEquals(String.class, underTest.getModelClassForRequest(request));
assertEquals(Integer.class, underTest.getModelClassForResource(resource));
// ensure that trying to reregister the resource type is a no-op
BundleContext secondBundleContext = MockOsgi.newBundleContext();
- underTest.registerModelToResourceType(secondBundleContext.getBundle(), "sling/rt/one", SlingHttpServletRequest.class, Integer.class);
+ underTest.registerModelToResourceType(
+ secondBundleContext.getBundle(), "sling/rt/one", SlingHttpServletRequest.class, Integer.class);
assertEquals(String.class, underTest.getModelClassForRequest(request));
underTest.removeResourceTypeBindings(bundleContext.getBundle());
@@ -250,7 +256,7 @@
public void testResourceTypeRegistrationForResourceWithoutResourceType() {
lenient().when(resource.getResourceType()).thenReturn(null);
lenient().when(resource.getResourceResolver()).thenReturn(resourceResolver);
- lenient().when(resourceResolver.getSearchPath()).thenReturn(new String[] { "/apps/", "/libs/" });
+ lenient().when(resourceResolver.getSearchPath()).thenReturn(new String[] {"/apps/", "/libs/"});
// ensure we don't have any registrations and no exception is thrown
assertNull(underTest.getModelClassForResource(resource));
@@ -258,16 +264,17 @@
static final class NoneImplementationPicker implements ImplementationPicker {
@Override
- public Class<?> pick(@NotNull Class<?> adapterType, Class<?> @NotNull [] implementationsTypes, @NotNull Object adaptable) {
+ public Class<?> pick(
+ @NotNull Class<?> adapterType, Class<?> @NotNull [] implementationsTypes, @NotNull Object adaptable) {
return null;
}
}
static final class LastImplementationPicker implements ImplementationPicker {
@Override
- public Class<?> pick(@NotNull Class<?> adapterType, Class<?> @NotNull [] implementationsTypes, @NotNull Object adaptable) {
+ public Class<?> pick(
+ @NotNull Class<?> adapterType, Class<?> @NotNull [] implementationsTypes, @NotNull Object adaptable) {
return implementationsTypes[implementationsTypes.length - 1];
}
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/AnnotationConflictsTest.java b/src/test/java/org/apache/sling/models/impl/AnnotationConflictsTest.java
index c2ae291..0cbcdb3 100644
--- a/src/test/java/org/apache/sling/models/impl/AnnotationConflictsTest.java
+++ b/src/test/java/org/apache/sling/models/impl/AnnotationConflictsTest.java
@@ -18,12 +18,6 @@
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
import java.util.Collections;
import org.apache.sling.api.resource.Resource;
@@ -45,6 +39,12 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
@SuppressWarnings("deprecation")
@RunWith(MockitoJUnitRunner.class)
public class AnnotationConflictsTest {
@@ -59,7 +59,8 @@
factory = AdapterFactoryTest.createModelAdapterFactory();
ValueMapInjector injector = new ValueMapInjector();
factory.bindInjector(injector, new ServicePropertiesMap(1, 1));
- factory.injectAnnotationProcessorFactories = Collections.<InjectAnnotationProcessorFactory>singletonList(new ValueMapInjector());
+ factory.injectAnnotationProcessorFactories =
+ Collections.<InjectAnnotationProcessorFactory>singletonList(new ValueMapInjector());
for (Class<?> clazz : this.getClass().getDeclaredClasses()) {
if (!clazz.isInterface()) {
@@ -263,6 +264,7 @@
private interface Methods {
String getOtherText();
+
String getEmptyText();
}
@@ -272,8 +274,13 @@
Methods model = factory.createModel(resource, modelClass);
assertNotNull("Adaptation to " + modelClass.getSimpleName() + " was not null.", model);
- assertNull("Adaptation to " + modelClass.getSimpleName() + " had a non-null emptyText value.", model.getEmptyText());
- assertEquals("Adaptation to " + modelClass.getSimpleName() + " had an unexpected value in the otherText value.", "hello", model.getOtherText());
+ assertNull(
+ "Adaptation to " + modelClass.getSimpleName() + " had a non-null emptyText value.",
+ model.getEmptyText());
+ assertEquals(
+ "Adaptation to " + modelClass.getSimpleName() + " had an unexpected value in the otherText value.",
+ "hello",
+ model.getOtherText());
}
private <T extends Methods> void failing(Class<T> modelClass) {
@@ -285,9 +292,14 @@
try {
factory.createModel(resource, modelClass);
} catch (MissingElementsException e) {
- assertEquals("Adaptation to " + modelClass.getSimpleName() + " failed, but with the wrong number of exceptions.",1, e.getMissingElements().size());
+ assertEquals(
+ "Adaptation to " + modelClass.getSimpleName() + " failed, but with the wrong number of exceptions.",
+ 1,
+ e.getMissingElements().size());
MissingElementException me = e.getMissingElements().iterator().next();
- assertTrue("Adaptation to " + modelClass.getSimpleName() + " didn't fail due to emptyText.", me.getElement().toString().endsWith("emptyText"));
+ assertTrue(
+ "Adaptation to " + modelClass.getSimpleName() + " didn't fail due to emptyText.",
+ me.getElement().toString().endsWith("emptyText"));
thrown = true;
}
assertTrue("Adaptation to " + modelClass.getSimpleName() + " was successful.", thrown);
diff --git a/src/test/java/org/apache/sling/models/impl/CachingTest.java b/src/test/java/org/apache/sling/models/impl/CachingTest.java
index 553f16c..f22ed75 100644
--- a/src/test/java/org/apache/sling/models/impl/CachingTest.java
+++ b/src/test/java/org/apache/sling/models/impl/CachingTest.java
@@ -1,28 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
import java.util.Collections;
import java.util.Enumeration;
@@ -47,6 +42,13 @@
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class CachingTest {
@@ -66,16 +68,20 @@
factory.bindInjector(new RequestAttributeInjector(), new ServicePropertiesMap(0, 0));
factory.bindInjector(new ValueMapInjector(), new ServicePropertiesMap(1, 1));
factory.adapterImplementations.addClassesAsAdapterAndImplementation(
- CachedModel.class,
- UncachedModel.class,
- org.apache.sling.models.testmodels.interfaces.CachedModel.class,
- org.apache.sling.models.testmodels.interfaces.UncachedModel.class);
+ CachedModel.class,
+ UncachedModel.class,
+ org.apache.sling.models.testmodels.interfaces.CachedModel.class,
+ org.apache.sling.models.testmodels.interfaces.UncachedModel.class);
factory.adapterImplementations.addAll(
- CachedModelWithAdapterTypes12.class,
- CachedModelWithAdapterTypes12.class, AdapterType1.class, AdapterType2.class);
+ CachedModelWithAdapterTypes12.class,
+ CachedModelWithAdapterTypes12.class,
+ AdapterType1.class,
+ AdapterType2.class);
factory.adapterImplementations.addAll(
- CachedModelWithAdapterTypes23.class,
- CachedModelWithAdapterTypes23.class, AdapterType2.class, AdapterType3.class);
+ CachedModelWithAdapterTypes23.class,
+ CachedModelWithAdapterTypes23.class,
+ AdapterType2.class,
+ AdapterType3.class);
when(request.getAttribute("testValue")).thenReturn("test");
requestWrapper = new SlingHttpServletRequestWrapper(request);
@@ -134,10 +140,10 @@
@Test
public void testCachedInterface() {
- org.apache.sling.models.testmodels.interfaces.CachedModel cached1 = factory.getAdapter(request,
- org.apache.sling.models.testmodels.interfaces.CachedModel.class);
- org.apache.sling.models.testmodels.interfaces.CachedModel cached2 = factory.getAdapter(request,
- org.apache.sling.models.testmodels.interfaces.CachedModel.class);
+ org.apache.sling.models.testmodels.interfaces.CachedModel cached1 =
+ factory.getAdapter(request, org.apache.sling.models.testmodels.interfaces.CachedModel.class);
+ org.apache.sling.models.testmodels.interfaces.CachedModel cached2 =
+ factory.getAdapter(request, org.apache.sling.models.testmodels.interfaces.CachedModel.class);
assertSame(cached1, cached2);
assertEquals("test", cached1.getTestValue());
@@ -148,10 +154,10 @@
@Test
public void testNoCachedInterface() {
- org.apache.sling.models.testmodels.interfaces.UncachedModel uncached1 = factory.getAdapter(request,
- org.apache.sling.models.testmodels.interfaces.UncachedModel.class);
- org.apache.sling.models.testmodels.interfaces.UncachedModel uncached2 = factory.getAdapter(request,
- org.apache.sling.models.testmodels.interfaces.UncachedModel.class);
+ org.apache.sling.models.testmodels.interfaces.UncachedModel uncached1 =
+ factory.getAdapter(request, org.apache.sling.models.testmodels.interfaces.UncachedModel.class);
+ org.apache.sling.models.testmodels.interfaces.UncachedModel uncached2 =
+ factory.getAdapter(request, org.apache.sling.models.testmodels.interfaces.UncachedModel.class);
assertNotSame(uncached1, uncached2);
assertEquals("test", uncached1.getTestValue());
@@ -182,10 +188,10 @@
@Test
public void testCachedInterfaceWithRequestWrapper() {
- org.apache.sling.models.testmodels.interfaces.CachedModel cached1 = factory.getAdapter(request,
- org.apache.sling.models.testmodels.interfaces.CachedModel.class);
- org.apache.sling.models.testmodels.interfaces.CachedModel cached2 = factory.getAdapter(requestWrapper,
- org.apache.sling.models.testmodels.interfaces.CachedModel.class);
+ org.apache.sling.models.testmodels.interfaces.CachedModel cached1 =
+ factory.getAdapter(request, org.apache.sling.models.testmodels.interfaces.CachedModel.class);
+ org.apache.sling.models.testmodels.interfaces.CachedModel cached2 =
+ factory.getAdapter(requestWrapper, org.apache.sling.models.testmodels.interfaces.CachedModel.class);
assertSame(cached1, cached2);
assertEquals("test", cached1.getTestValue());
@@ -196,19 +202,20 @@
@Test
public void testCachedModelWithAdapterTypes() {
- // test 2 model implementations that share a common adapter type, with an implementation picker that selects exactly one of the
+ // test 2 model implementations that share a common adapter type, with an implementation picker that selects
+ // exactly one of the
// implementations for the common adapter type. verify that the models are cached accordingly
factory.bindImplementationPicker(
- (adapterType, impls, adaptable) -> {
- if (AdapterType1.class.equals(adapterType)) {
- return CachedModelWithAdapterTypes12.class;
- } else if (AdapterType2.class.equals(adapterType) || AdapterType3.class.equals(adapterType)) {
- return CachedModelWithAdapterTypes23.class;
- } else {
- return null;
- }
- },
- new ServicePropertiesMap(2, 0));
+ (adapterType, impls, adaptable) -> {
+ if (AdapterType1.class.equals(adapterType)) {
+ return CachedModelWithAdapterTypes12.class;
+ } else if (AdapterType2.class.equals(adapterType) || AdapterType3.class.equals(adapterType)) {
+ return CachedModelWithAdapterTypes23.class;
+ } else {
+ return null;
+ }
+ },
+ new ServicePropertiesMap(2, 0));
CachedModelWithAdapterTypes12 byImpl12 = factory.getAdapter(request, CachedModelWithAdapterTypes12.class);
CachedModelWithAdapterTypes23 byImpl23 = factory.getAdapter(request, CachedModelWithAdapterTypes23.class);
@@ -221,4 +228,3 @@
assertSame(byImpl23, byAdapterType3);
}
}
-
diff --git a/src/test/java/org/apache/sling/models/impl/ConstructorTest.java b/src/test/java/org/apache/sling/models/impl/ConstructorTest.java
index 5507a5c..7bfc250 100644
--- a/src/test/java/org/apache/sling/models/impl/ConstructorTest.java
+++ b/src/test/java/org/apache/sling/models/impl/ConstructorTest.java
@@ -1,29 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
@@ -54,6 +48,14 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class ConstructorTest {
@@ -84,8 +86,7 @@
InvalidConstructorModel.class,
WithThreeConstructorsOneInjectModel.class,
NoNameModel.class,
- ViaRequestSuffixModel.class
- );
+ ViaRequestSuffixModel.class);
}
@Test
@@ -137,8 +138,8 @@
*/
@Test
public void testThreeConstructorsOneInjectInjection() {
- WithThreeConstructorsOneInjectModel model = factory.getAdapter(request,
- WithThreeConstructorsOneInjectModel.class);
+ WithThreeConstructorsOneInjectModel model =
+ factory.getAdapter(request, WithThreeConstructorsOneInjectModel.class);
assertNotNull(model);
assertNull(model.getRequest());
assertEquals(INT_VALUE, model.getAttribute());
diff --git a/src/test/java/org/apache/sling/models/impl/ConstructorVisibilityTest.java b/src/test/java/org/apache/sling/models/impl/ConstructorVisibilityTest.java
index b1c449f..115bd0b 100644
--- a/src/test/java/org/apache/sling/models/impl/ConstructorVisibilityTest.java
+++ b/src/test/java/org/apache/sling/models/impl/ConstructorVisibilityTest.java
@@ -1,23 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertNotNull;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.impl.injectors.RequestAttributeInjector;
import org.apache.sling.models.impl.injectors.SelfInjector;
@@ -30,6 +30,8 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertNotNull;
+
@RunWith(MockitoJUnitRunner.class)
public class ConstructorVisibilityTest {
private ModelAdapterFactory factory;
@@ -42,7 +44,8 @@
factory = AdapterFactoryTest.createModelAdapterFactory();
factory.bindInjector(new RequestAttributeInjector(), new ServicePropertiesMap(1, 1));
factory.bindInjector(new SelfInjector(), new ServicePropertiesMap(2, 2));
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(ProtectedConstructorModel.class, PackagePrivateConstructorModel.class, PrivateConstructorModel.class);
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ ProtectedConstructorModel.class, PackagePrivateConstructorModel.class, PrivateConstructorModel.class);
}
@Test
@@ -50,13 +53,13 @@
ProtectedConstructorModel model = factory.createModel(request, ProtectedConstructorModel.class);
assertNotNull(model);
}
-
+
@Test
public void testNonPublicConstructorPackagePrivateModel() {
PackagePrivateConstructorModel model = factory.createModel(request, PackagePrivateConstructorModel.class);
assertNotNull(model);
}
-
+
@Test
public void testNonPublicConstructorPrivateModel() {
PrivateConstructorModel model = factory.createModel(request, PrivateConstructorModel.class);
diff --git a/src/test/java/org/apache/sling/models/impl/CustomInjectorTest.java b/src/test/java/org/apache/sling/models/impl/CustomInjectorTest.java
index c84c714..f149af2 100644
--- a/src/test/java/org/apache/sling/models/impl/CustomInjectorTest.java
+++ b/src/test/java/org/apache/sling/models/impl/CustomInjectorTest.java
@@ -1,28 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import javax.inject.Inject;
import java.util.Collections;
-import javax.inject.Inject;
-
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.impl.injector.CustomAnnotation;
import org.apache.sling.models.impl.injector.CustomAnnotationInjector;
@@ -33,6 +32,9 @@
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
@SuppressWarnings("deprecation")
@RunWith(MockitoJUnitRunner.class)
public class CustomInjectorTest {
@@ -42,7 +44,8 @@
@Before
public void setup() {
factory = AdapterFactoryTest.createModelAdapterFactory();
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(TestModel.class, CustomAnnotationModel.class);
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ TestModel.class, CustomAnnotationModel.class);
}
@Test
@@ -60,7 +63,8 @@
factory.bindInjector(new SimpleInjector(), new ServicePropertiesMap(1, 1));
factory.bindInjector(injector, new ServicePropertiesMap(1, 1));
- factory.injectAnnotationProcessorFactories = factory.injectAnnotationProcessorFactories = Collections.<InjectAnnotationProcessorFactory>singletonList(injector);
+ factory.injectAnnotationProcessorFactories = factory.injectAnnotationProcessorFactories =
+ Collections.<InjectAnnotationProcessorFactory>singletonList(injector);
CustomAnnotationModel model = factory.getAdapter(new Object(), CustomAnnotationModel.class);
assertNotNull(model);
@@ -82,5 +86,4 @@
@Inject
String getCustomString();
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/DefaultInterfaceMethodTest.java b/src/test/java/org/apache/sling/models/impl/DefaultInterfaceMethodTest.java
index 5798c67..01f1db9 100644
--- a/src/test/java/org/apache/sling/models/impl/DefaultInterfaceMethodTest.java
+++ b/src/test/java/org/apache/sling/models/impl/DefaultInterfaceMethodTest.java
@@ -1,21 +1,25 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
+import java.util.Collections;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.wrappers.ValueMapDecorator;
@@ -24,8 +28,6 @@
import org.junit.Before;
import org.junit.Test;
-import java.util.Collections;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.lenient;
@@ -48,7 +50,7 @@
Resource res = mock(Resource.class);
lenient().when(res.adaptTo(ValueMap.class)).thenReturn(vm);
- ModelWithDefaultMethods model = factory.getAdapter(res,ModelWithDefaultMethods.class);
+ ModelWithDefaultMethods model = factory.getAdapter(res, ModelWithDefaultMethods.class);
assertEquals("the prop", model.getProp());
}
@@ -59,7 +61,7 @@
Resource res = mock(Resource.class);
lenient().when(res.adaptTo(ValueMap.class)).thenReturn(vm);
- ModelWithDefaultMethods model = factory.getAdapter(res,ModelWithDefaultMethods.class);
+ ModelWithDefaultMethods model = factory.getAdapter(res, ModelWithDefaultMethods.class);
assertNull(model.getProp());
}
diff --git a/src/test/java/org/apache/sling/models/impl/DefaultTest.java b/src/test/java/org/apache/sling/models/impl/DefaultTest.java
index 4963853..ccf5f0f 100644
--- a/src/test/java/org/apache/sling/models/impl/DefaultTest.java
+++ b/src/test/java/org/apache/sling/models/impl/DefaultTest.java
@@ -1,29 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.lenient;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import java.util.Arrays;
import java.util.Collections;
@@ -40,6 +34,14 @@
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class DefaultTest {
@@ -49,7 +51,14 @@
public void setup() {
factory = AdapterFactoryTest.createModelAdapterFactory();
factory.bindInjector(new ValueMapInjector(), new ServicePropertiesMap(0, 0));
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(DefaultStringModel.class, PropertyModelWithDefaults.class, DefaultPrimitivesModel.class, DefaultWrappersModel.class, org.apache.sling.models.testmodels.classes.constructorinjection.DefaultPrimitivesModel.class, org.apache.sling.models.testmodels.classes.constructorinjection.DefaultStringModel.class, org.apache.sling.models.testmodels.classes.constructorinjection.DefaultWrappersModel.class);
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ DefaultStringModel.class,
+ PropertyModelWithDefaults.class,
+ DefaultPrimitivesModel.class,
+ DefaultWrappersModel.class,
+ org.apache.sling.models.testmodels.classes.constructorinjection.DefaultPrimitivesModel.class,
+ org.apache.sling.models.testmodels.classes.constructorinjection.DefaultStringModel.class,
+ org.apache.sling.models.testmodels.classes.constructorinjection.DefaultWrappersModel.class);
}
@Test
@@ -78,7 +87,6 @@
assertEquals("second default", model.getSecond());
}
-
@Test
public void testDefaultPrimitivesField() {
ValueMap vm = new ValueMapDecorator(Collections.<String, Object>emptyMap());
@@ -90,11 +98,12 @@
assertNotNull(model);
assertEquals(true, model.getBooleanProperty());
- // we need to wait for JUnit 4.12 for this assertArrayEquals to be working on primitive boolean arrays, https://github.com/junit-team/junit/issues/86!
- assertTrue(Arrays.equals(new boolean[] { true, true }, model.getBooleanArrayProperty()));
+ // we need to wait for JUnit 4.12 for this assertArrayEquals to be working on primitive boolean arrays,
+ // https://github.com/junit-team/junit/issues/86!
+ assertTrue(Arrays.equals(new boolean[] {true, true}, model.getBooleanArrayProperty()));
assertEquals(1L, model.getLongProperty());
- assertArrayEquals(new long[] { 1L, 1L }, model.getLongArrayProperty());
+ assertArrayEquals(new long[] {1L, 1L}, model.getLongArrayProperty());
}
@Test
@@ -108,11 +117,12 @@
assertNotNull(model);
assertEquals(Boolean.valueOf(true), model.getBooleanWrapperProperty());
- // we need to wait for JUnit 4.12 for this assertArrayEquals to be working on primitive boolean arrays, https://github.com/junit-team/junit/issues/86!
- assertTrue(Arrays.equals(new Boolean[] { Boolean.TRUE, Boolean.TRUE }, model.getBooleanWrapperArrayProperty()));
+ // we need to wait for JUnit 4.12 for this assertArrayEquals to be working on primitive boolean arrays,
+ // https://github.com/junit-team/junit/issues/86!
+ assertTrue(Arrays.equals(new Boolean[] {Boolean.TRUE, Boolean.TRUE}, model.getBooleanWrapperArrayProperty()));
assertEquals(Long.valueOf(1L), model.getLongWrapperProperty());
- assertArrayEquals(new Long[] { Long.valueOf(1L), Long.valueOf(1L) }, model.getLongWrapperArrayProperty());
+ assertArrayEquals(new Long[] {Long.valueOf(1L), Long.valueOf(1L)}, model.getLongWrapperArrayProperty());
}
@Test
@@ -122,8 +132,8 @@
Resource res = mock(Resource.class);
lenient().when(res.adaptTo(ValueMap.class)).thenReturn(vm);
- org.apache.sling.models.testmodels.classes.constructorinjection.DefaultStringModel model
- = factory.getAdapter(res, org.apache.sling.models.testmodels.classes.constructorinjection.DefaultStringModel.class);
+ org.apache.sling.models.testmodels.classes.constructorinjection.DefaultStringModel model = factory.getAdapter(
+ res, org.apache.sling.models.testmodels.classes.constructorinjection.DefaultStringModel.class);
assertNotNull(model);
assertEquals("firstDefault", model.getFirstProperty());
assertEquals(2, model.getSecondProperty().length);
@@ -136,16 +146,19 @@
Resource res = mock(Resource.class);
lenient().when(res.adaptTo(ValueMap.class)).thenReturn(vm);
- org.apache.sling.models.testmodels.classes.constructorinjection.DefaultPrimitivesModel model
- = factory.getAdapter(res, org.apache.sling.models.testmodels.classes.constructorinjection.DefaultPrimitivesModel.class);
+ org.apache.sling.models.testmodels.classes.constructorinjection.DefaultPrimitivesModel model =
+ factory.getAdapter(
+ res,
+ org.apache.sling.models.testmodels.classes.constructorinjection.DefaultPrimitivesModel.class);
assertNotNull(model);
assertEquals(true, model.getBooleanProperty());
- // we need to wait for JUnit 4.12 for this assertArrayEquals to be working on primitive boolean arrays, https://github.com/junit-team/junit/issues/86!
- assertTrue(Arrays.equals(new boolean[] { true, true }, model.getBooleanArrayProperty()));
+ // we need to wait for JUnit 4.12 for this assertArrayEquals to be working on primitive boolean arrays,
+ // https://github.com/junit-team/junit/issues/86!
+ assertTrue(Arrays.equals(new boolean[] {true, true}, model.getBooleanArrayProperty()));
assertEquals(1L, model.getLongProperty());
- assertArrayEquals(new long[] { 1L, 1L }, model.getLongArrayProperty());
+ assertArrayEquals(new long[] {1L, 1L}, model.getLongArrayProperty());
}
@Test
@@ -155,16 +168,16 @@
Resource res = mock(Resource.class);
lenient().when(res.adaptTo(ValueMap.class)).thenReturn(vm);
- org.apache.sling.models.testmodels.classes.constructorinjection.DefaultWrappersModel model
- = factory.getAdapter(res, org.apache.sling.models.testmodels.classes.constructorinjection.DefaultWrappersModel.class);
+ org.apache.sling.models.testmodels.classes.constructorinjection.DefaultWrappersModel model = factory.getAdapter(
+ res, org.apache.sling.models.testmodels.classes.constructorinjection.DefaultWrappersModel.class);
assertNotNull(model);
assertEquals(Boolean.valueOf(true), model.getBooleanWrapperProperty());
- // we need to wait for JUnit 4.12 for this assertArrayEquals to be working on primitive boolean arrays, https://github.com/junit-team/junit/issues/86!
- assertTrue(Arrays.equals(new Boolean[] { Boolean.TRUE, Boolean.TRUE }, model.getBooleanWrapperArrayProperty()));
+ // we need to wait for JUnit 4.12 for this assertArrayEquals to be working on primitive boolean arrays,
+ // https://github.com/junit-team/junit/issues/86!
+ assertTrue(Arrays.equals(new Boolean[] {Boolean.TRUE, Boolean.TRUE}, model.getBooleanWrapperArrayProperty()));
assertEquals(Long.valueOf(1L), model.getLongWrapperProperty());
- assertArrayEquals(new Long[] { Long.valueOf(1L), Long.valueOf(1L) }, model.getLongWrapperArrayProperty());
+ assertArrayEquals(new Long[] {Long.valueOf(1L), Long.valueOf(1L)}, model.getLongWrapperArrayProperty());
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/ExtraDefaultTests.java b/src/test/java/org/apache/sling/models/impl/ExtraDefaultTests.java
index 03576be..a72ec4c 100644
--- a/src/test/java/org/apache/sling/models/impl/ExtraDefaultTests.java
+++ b/src/test/java/org/apache/sling/models/impl/ExtraDefaultTests.java
@@ -1,24 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
import javax.inject.Inject;
import org.apache.sling.api.resource.Resource;
@@ -30,6 +29,9 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
@RunWith(MockitoJUnitRunner.class)
public class ExtraDefaultTests {
@@ -41,7 +43,8 @@
@Before
public void setup() {
factory = AdapterFactoryTest.createModelAdapterFactory();
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(EmptyDefaultsModel.class, WrongTypeDefaultsModel.class);
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ EmptyDefaultsModel.class, WrongTypeDefaultsModel.class);
}
@Test
@@ -135,7 +138,7 @@
@Inject
@Default
private short[] shortArray;
-
+
@Inject
@Default
private Boolean[] booleanWrapperArray;
@@ -215,39 +218,37 @@
@Inject
@Default
private String singleString;
-
}
@Model(adaptables = Resource.class)
public static class WrongTypeDefaultsModel {
@Inject
- @Default(intValues = { 1, 1 })
+ @Default(intValues = {1, 1})
private boolean[] booleanArray;
@Inject
- @Default(intValues = { 1, 1 })
+ @Default(intValues = {1, 1})
private double[] doubleArray;
@Inject
- @Default(intValues = { 1, 1 })
+ @Default(intValues = {1, 1})
private float[] floatArray;
@Inject
- @Default(longValues = { 1, 1 })
+ @Default(longValues = {1, 1})
private int[] intArray;
@Inject
- @Default(intValues = { 1, 1 })
+ @Default(intValues = {1, 1})
private long[] longArray;
@Inject
- @Default(intValues = { 1, 1 })
+ @Default(intValues = {1, 1})
private short[] shortArray;
@Inject
- @Default(intValues = { 1, 1 })
+ @Default(intValues = {1, 1})
private String[] stringArray;
-
}
}
diff --git a/src/test/java/org/apache/sling/models/impl/ImplementsExtendsTest.java b/src/test/java/org/apache/sling/models/impl/ImplementsExtendsTest.java
index 3520722..352f464 100644
--- a/src/test/java/org/apache/sling/models/impl/ImplementsExtendsTest.java
+++ b/src/test/java/org/apache/sling/models/impl/ImplementsExtendsTest.java
@@ -1,30 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Dictionary;
@@ -63,6 +56,15 @@
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class ImplementsExtendsTest {
@@ -86,30 +88,32 @@
@SuppressWarnings("unchecked")
@Before
public void setup() throws ClassNotFoundException, MalformedURLException {
- when(bundleContext.registerService(anyString(), any(), any(Dictionary.class))).then(new Answer<ServiceRegistration>() {
- @Override
- public ServiceRegistration<?> answer(InvocationOnMock invocation) throws Throwable {
- final Dictionary<String, Object> props = (Dictionary<String, Object>)invocation.getArguments()[2];
- ServiceRegistration reg = mock(ServiceRegistration.class);
- ServiceReference ref = mock(ServiceReference.class);
- when(reg.getReference()).thenReturn(ref);
- when(ref.getProperty(anyString())).thenAnswer(new Answer<Object>() {
+ when(bundleContext.registerService(anyString(), any(), any(Dictionary.class)))
+ .then(new Answer<ServiceRegistration>() {
@Override
- public Object answer(InvocationOnMock invocation) throws Throwable {
- String key = (String)invocation.getArguments()[0];
- return props.get(key);
+ public ServiceRegistration<?> answer(InvocationOnMock invocation) throws Throwable {
+ final Dictionary<String, Object> props =
+ (Dictionary<String, Object>) invocation.getArguments()[2];
+ ServiceRegistration reg = mock(ServiceRegistration.class);
+ ServiceReference ref = mock(ServiceReference.class);
+ when(reg.getReference()).thenReturn(ref);
+ when(ref.getProperty(anyString())).thenAnswer(new Answer<Object>() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ String key = (String) invocation.getArguments()[0];
+ return props.get(key);
+ }
+ });
+ return reg;
}
});
- return reg;
- }
- });
factory = AdapterFactoryTest.createModelAdapterFactory(bundleContext);
factory.bindInjector(new ValueMapInjector(), new ServicePropertiesMap(2, 2));
factory.bindImplementationPicker(firstImplementationPicker, firstImplementationPickerProps);
// simulate bundle add for ModelPackageBundleListener
- Dictionary<String, String> headers = new Hashtable<String,String>();
+ Dictionary<String, String> headers = new Hashtable<String, String>();
headers.put(ModelPackageBundleListener.PACKAGE_HEADER, "org.apache.sling.models.testmodels.classes.implextend");
when(bundle.getHeaders()).thenReturn(headers);
@@ -126,7 +130,7 @@
when(bundle.loadClass(anyString())).then(new Answer<Class<?>>() {
@Override
public Class<?> answer(InvocationOnMock invocation) throws ClassNotFoundException {
- String className = (String)invocation.getArguments()[0];
+ String className = (String) invocation.getArguments()[0];
return ImplementsExtendsTest.this.getClass().getClassLoader().loadClass(className);
}
});
@@ -148,7 +152,8 @@
Resource res = getMockResourceWithProps();
try {
factory.getAdapter(res, SampleServiceInterface.class);
- Assert.fail("Getting the model for interface 'SampleServiceInterface' should fail after the accroding adapter factory has been unregistered");
+ Assert.fail(
+ "Getting the model for interface 'SampleServiceInterface' should fail after the accroding adapter factory has been unregistered");
} catch (ModelClassException e) {
}
@@ -187,7 +192,7 @@
* Try to adapt in a case where there is no picker available.
* The case where the class is the adapter still works.
*/
- @Test(expected=ModelClassException.class)
+ @Test(expected = ModelClassException.class)
public void testImplementsNoPickerWithDifferentImplementations() {
factory.unbindImplementationPicker(firstImplementationPicker, firstImplementationPickerProps);
@@ -212,7 +217,7 @@
/**
* Test implementation class with a mapping that is not valid (an interface that is not implemented).
*/
- @Test(expected=ModelClassException.class)
+ @Test(expected = ModelClassException.class)
public void testInvalidImplementsInterfaceModel() {
Resource res = getMockResourceWithProps();
factory.getAdapter(res, InvalidSampleServiceInterface.class);
@@ -242,7 +247,8 @@
*/
@Test
public void testImplementsInterfaceModelWithPickLastImplementationPicker() {
- factory.bindImplementationPicker(new AdapterImplementationsTest.LastImplementationPicker(), new ServicePropertiesMap(3, 1));
+ factory.bindImplementationPicker(
+ new AdapterImplementationsTest.LastImplementationPicker(), new ServicePropertiesMap(3, 1));
Resource res = getMockResourceWithProps();
SampleServiceInterface model = factory.getAdapter(res, SampleServiceInterface.class);
@@ -262,5 +268,4 @@
when(res.adaptTo(ValueMap.class)).thenReturn(vm);
return res;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/InjectorSpecificAnnotationTest.java b/src/test/java/org/apache/sling/models/impl/InjectorSpecificAnnotationTest.java
index 2b96c43..b50d67b 100644
--- a/src/test/java/org/apache/sling/models/impl/InjectorSpecificAnnotationTest.java
+++ b/src/test/java/org/apache/sling/models/impl/InjectorSpecificAnnotationTest.java
@@ -1,26 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -53,6 +50,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
@SuppressWarnings("deprecation")
public class InjectorSpecificAnnotationTest {
@@ -82,31 +84,32 @@
ChildResourceInjector childResourceInjector = new ChildResourceInjector();
RequestAttributeInjector requestAttributeInjector = new RequestAttributeInjector();
- factory.bindInjector(bindingsInjector,
- Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 1L));
- factory.bindInjector(valueMapInjector,
- Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 2L));
- factory.bindInjector(childResourceInjector,
- Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 3L));
- factory.bindInjector(requestAttributeInjector,
- Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 4L));
- factory.bindInjector(osgiInjector, Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 5L));
+ factory.bindInjector(bindingsInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 1L));
+ factory.bindInjector(valueMapInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 2L));
+ factory.bindInjector(childResourceInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 3L));
+ factory.bindInjector(
+ requestAttributeInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 4L));
+ factory.bindInjector(osgiInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 5L));
- factory.bindStaticInjectAnnotationProcessorFactory(bindingsInjector,
- Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 1L));
- factory.injectAnnotationProcessorFactories = Collections.<InjectAnnotationProcessorFactory>singletonList(valueMapInjector);
- factory.injectAnnotationProcessorFactories2 = Collections.<InjectAnnotationProcessorFactory2>singletonList(childResourceInjector);
- factory.bindStaticInjectAnnotationProcessorFactory(requestAttributeInjector,
- Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 4L));
- factory.bindStaticInjectAnnotationProcessorFactory(osgiInjector,
- Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 5L));
+ factory.bindStaticInjectAnnotationProcessorFactory(
+ bindingsInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 1L));
+ factory.injectAnnotationProcessorFactories =
+ Collections.<InjectAnnotationProcessorFactory>singletonList(valueMapInjector);
+ factory.injectAnnotationProcessorFactories2 =
+ Collections.<InjectAnnotationProcessorFactory2>singletonList(childResourceInjector);
+ factory.bindStaticInjectAnnotationProcessorFactory(
+ requestAttributeInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 4L));
+ factory.bindStaticInjectAnnotationProcessorFactory(
+ osgiInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 5L));
factory.bindViaProvider(new BeanPropertyViaProvider(), null);
SlingBindings bindings = new SlingBindings();
bindings.setLog(log);
Mockito.when(request.getAttribute(SlingBindings.class.getName())).thenReturn(bindings);
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(InjectorSpecificAnnotationModel.class, org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel.class);
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ InjectorSpecificAnnotationModel.class,
+ org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel.class);
}
@Test
@@ -149,12 +152,11 @@
}
@Test
- @SuppressWarnings({ "unchecked", "null" })
+ @SuppressWarnings({"unchecked", "null"})
public void testOSGiServiceField() throws InvalidSyntaxException {
ServiceReference ref = mock(ServiceReference.class);
Logger log = mock(Logger.class);
- when(bundleContext.getServiceReferences(Logger.class.getName(), null)).thenReturn(
- new ServiceReference[] { ref });
+ when(bundleContext.getServiceReferences(Logger.class.getName(), null)).thenReturn(new ServiceReference[] {ref});
when(bundleContext.getService(ref)).thenReturn(log);
InjectorSpecificAnnotationModel model = factory.getAdapter(request, InjectorSpecificAnnotationModel.class);
@@ -207,8 +209,11 @@
when(res.adaptTo(ValueMap.class)).thenReturn(vm);
when(request.getResource()).thenReturn(res);
- org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel model
- = factory.getAdapter(request, org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel.class);
+ org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel model =
+ factory.getAdapter(
+ request,
+ org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel
+ .class);
assertNotNull("Could not instanciate model", model);
assertEquals("first-value", model.getFirst());
assertEquals("second-value", model.getSecond());
@@ -230,24 +235,29 @@
when(res.adaptTo(ValueMap.class)).thenReturn(vm);
when(request.getResource()).thenReturn(res);
- org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel model
- = factory.getAdapter(request, org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel.class);
+ org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel model =
+ factory.getAdapter(
+ request,
+ org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel
+ .class);
assertNotNull("Could not instanciate model", model);
assertEquals("first-value", model.getFirst());
assertEquals(logFromValueMap, model.getLog());
}
@Test
- @SuppressWarnings({ "unchecked", "null" })
+ @SuppressWarnings({"unchecked", "null"})
public void testOSGiServiceConstructor() throws InvalidSyntaxException {
ServiceReference ref = mock(ServiceReference.class);
Logger log = mock(Logger.class);
- when(bundleContext.getServiceReferences(Logger.class.getName(), null)).thenReturn(
- new ServiceReference[] { ref });
+ when(bundleContext.getServiceReferences(Logger.class.getName(), null)).thenReturn(new ServiceReference[] {ref});
when(bundleContext.getService(ref)).thenReturn(log);
- org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel model
- = factory.getAdapter(request, org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel.class);
+ org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel model =
+ factory.getAdapter(
+ request,
+ org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel
+ .class);
assertNotNull("Could not instanciate model", model);
assertEquals(log, model.getService());
}
@@ -259,8 +269,11 @@
bindings.setSling(helper);
when(request.getAttribute(SlingBindings.class.getName())).thenReturn(bindings);
- org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel model
- = factory.getAdapter(request, org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel.class);
+ org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel model =
+ factory.getAdapter(
+ request,
+ org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel
+ .class);
assertNotNull("Could not instanciate model", model);
assertEquals(helper, model.getHelper());
}
@@ -270,8 +283,11 @@
Object attribute = new Object();
when(request.getAttribute("attribute")).thenReturn(attribute);
- org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel model
- = factory.getAdapter(request, org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel.class);
+ org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel model =
+ factory.getAdapter(
+ request,
+ org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel
+ .class);
assertNotNull("Could not instanciate model", model);
assertEquals(attribute, model.getRequestAttribute());
}
@@ -283,10 +299,12 @@
when(res.getChild("child1")).thenReturn(child);
when(request.getResource()).thenReturn(res);
- org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel model
- = factory.getAdapter(request, org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel.class);
+ org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel model =
+ factory.getAdapter(
+ request,
+ org.apache.sling.models.testmodels.classes.constructorinjection.InjectorSpecificAnnotationModel
+ .class);
assertNotNull("Could not instanciate model", model);
assertEquals(child, model.getChildResource());
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/InterfaceInheritanceTest.java b/src/test/java/org/apache/sling/models/impl/InterfaceInheritanceTest.java
index 66a54b5..f6b0365 100644
--- a/src/test/java/org/apache/sling/models/impl/InterfaceInheritanceTest.java
+++ b/src/test/java/org/apache/sling/models/impl/InterfaceInheritanceTest.java
@@ -1,26 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -37,6 +34,11 @@
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
@SuppressWarnings("deprecation")
@RunWith(MockitoJUnitRunner.class)
public class InterfaceInheritanceTest {
@@ -49,7 +51,8 @@
ValueMapInjector valueMapInjector = new ValueMapInjector();
factory.bindInjector(valueMapInjector, new ServicePropertiesMap(1, 2));
- factory.injectAnnotationProcessorFactories = Collections.<InjectAnnotationProcessorFactory>singletonList(valueMapInjector);
+ factory.injectAnnotationProcessorFactories =
+ Collections.<InjectAnnotationProcessorFactory>singletonList(valueMapInjector);
factory.adapterImplementations.addClassesAsAdapterAndImplementation(SuperClassModel.class, SubClassModel.class);
}
diff --git a/src/test/java/org/apache/sling/models/impl/InvalidAdaptationsTest.java b/src/test/java/org/apache/sling/models/impl/InvalidAdaptationsTest.java
index eb6e151..fb0deea 100644
--- a/src/test/java/org/apache/sling/models/impl/InvalidAdaptationsTest.java
+++ b/src/test/java/org/apache/sling/models/impl/InvalidAdaptationsTest.java
@@ -1,25 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.lenient;
-import static org.mockito.Mockito.mock;
-
import java.util.Collections;
import java.util.Map;
@@ -37,6 +35,10 @@
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.mock;
+
@RunWith(MockitoJUnitRunner.class)
public class InvalidAdaptationsTest {
private ModelAdapterFactory factory;
@@ -51,7 +53,7 @@
@Test
public void testNonModelClass() {
- Map<String, Object> emptyMap = Collections.<String, Object> emptyMap();
+ Map<String, Object> emptyMap = Collections.<String, Object>emptyMap();
Resource res = mock(Resource.class);
lenient().when(res.adaptTo(ValueMap.class)).thenReturn(new ValueMapDecorator(emptyMap));
@@ -61,7 +63,7 @@
@Test(expected = ModelClassException.class)
public void testNonModelClassException() {
- Map<String, Object> emptyMap = Collections.<String, Object> emptyMap();
+ Map<String, Object> emptyMap = Collections.<String, Object>emptyMap();
Resource res = mock(Resource.class);
lenient().when(res.adaptTo(ValueMap.class)).thenReturn(new ValueMapDecorator(emptyMap));
@@ -71,7 +73,7 @@
@Test
public void testWrongAdaptableClass() {
- Map<String, Object> emptyMap = Collections.<String, Object> emptyMap();
+ Map<String, Object> emptyMap = Collections.<String, Object>emptyMap();
Resource res = mock(Resource.class);
lenient().when(res.adaptTo(ValueMap.class)).thenReturn(new ValueMapDecorator(emptyMap));
@@ -81,7 +83,7 @@
@Test(expected = InvalidAdaptableException.class)
public void testWrongAdaptableClassException() {
- Map<String, Object> emptyMap = Collections.<String, Object> emptyMap();
+ Map<String, Object> emptyMap = Collections.<String, Object>emptyMap();
Resource res = mock(Resource.class);
lenient().when(res.adaptTo(ValueMap.class)).thenReturn(new ValueMapDecorator(emptyMap));
@@ -89,11 +91,8 @@
assertNull(factory.createModel(res, RequestModel.class));
}
- private class NonModel {
- }
+ private class NonModel {}
@Model(adaptables = SlingHttpServletRequest.class)
- private class RequestModel {
- }
-
+ private class RequestModel {}
}
diff --git a/src/test/java/org/apache/sling/models/impl/ModelPackageBundleListenerTest.java b/src/test/java/org/apache/sling/models/impl/ModelPackageBundleListenerTest.java
index 0872409..3f340fc 100644
--- a/src/test/java/org/apache/sling/models/impl/ModelPackageBundleListenerTest.java
+++ b/src/test/java/org/apache/sling/models/impl/ModelPackageBundleListenerTest.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
@@ -57,17 +59,20 @@
private static final class HideClassesClassLoader extends OverridingClassLoader {
private final Collection<String> classNamesToHide;
+
public HideClassesClassLoader(ClassLoader parent, String... classNamesToHide) {
super(parent);
this.classNamesToHide = Arrays.asList(classNamesToHide);
- //Exclude Hidden class since its loading via default class loader and throws ClassNotFoundException in line:70
+ // Exclude Hidden class since its loading via default class loader and throws ClassNotFoundException in
+ // line:70
this.excludeClass(Hidden.class.getName());
}
@Override
protected Class<?> loadClassForOverriding(String name) throws ClassNotFoundException {
if (classNamesToHide.contains(name)) {
- throw new ClassNotFoundException("Could not find class " + name + " as it is hidden by this class loader!");
+ throw new ClassNotFoundException(
+ "Could not find class " + name + " as it is hidden by this class loader!");
}
return super.loadClassForOverriding(name);
}
@@ -75,31 +80,39 @@
@Test
public void testAddingBundleWithResolvableModelAnnotation() throws ClassNotFoundException {
- Assert.assertFalse("Model should not yet have been registered but was", adapterImplementations.isModelClass(ChildModel.class));
+ Assert.assertFalse(
+ "Model should not yet have been registered but was",
+ adapterImplementations.isModelClass(ChildModel.class));
ModelPackageBundleListener listener = createListenerForBundleWithClass(ChildModel.class);
listener.addingBundle(mockBundle, new BundleEvent(BundleEvent.STARTED, mockBundle));
- Assert.assertTrue("Model should have been registered but was not", adapterImplementations.isModelClass(ChildModel.class));
+ Assert.assertTrue(
+ "Model should have been registered but was not", adapterImplementations.isModelClass(ChildModel.class));
}
@Test
public void testAddingBundleWithNonResolvableNonModelAnnotation() throws ClassNotFoundException {
ClassLoader classLoader = new HideClassesClassLoader(this.getClass().getClassLoader(), Hidden.class.getName());
- ModelPackageBundleListener listener = createListenerForBundleWithClass(classLoader, SimpleModelWithInvalidSecondAnnotation.class.getName());
+ ModelPackageBundleListener listener =
+ createListenerForBundleWithClass(classLoader, SimpleModelWithInvalidSecondAnnotation.class.getName());
listener.addingBundle(mockBundle, new BundleEvent(BundleEvent.STARTED, mockBundle));
- Assert.assertFalse("Model should not yet have been registered but was", adapterImplementations.isModelClass(SimpleModelWithInvalidSecondAnnotation.class));
+ Assert.assertFalse(
+ "Model should not yet have been registered but was",
+ adapterImplementations.isModelClass(SimpleModelWithInvalidSecondAnnotation.class));
}
- private ModelPackageBundleListener createListenerForBundleWithClass(Class<?> modelClass) throws ClassNotFoundException {
+ private ModelPackageBundleListener createListenerForBundleWithClass(Class<?> modelClass)
+ throws ClassNotFoundException {
return createListenerForBundleWithClass(modelClass.getClassLoader(), modelClass.getName());
}
- private ModelPackageBundleListener createListenerForBundleWithClass(ClassLoader classLoader, String className) throws ClassNotFoundException {
+ private ModelPackageBundleListener createListenerForBundleWithClass(ClassLoader classLoader, String className)
+ throws ClassNotFoundException {
Dictionary<String, String> headers = new Hashtable<>();
headers.put(ModelPackageBundleListener.CLASSES_HEADER, className);
Mockito.when(mockBundle.getHeaders()).thenReturn(headers);
- Mockito.when(mockBundle.loadClass(Mockito.anyString())).thenAnswer(new Answer<Class<?>>(){
+ Mockito.when(mockBundle.loadClass(Mockito.anyString())).thenAnswer(new Answer<Class<?>>() {
@Override
- public Class<?>answer(InvocationOnMock invocation) throws Throwable {
+ public Class<?> answer(InvocationOnMock invocation) throws Throwable {
Object argument = invocation.getArguments()[0];
if (argument.equals(className)) {
return classLoader.loadClass(className);
@@ -108,7 +121,7 @@
}
}
});
- return new ModelPackageBundleListener(mockBundleContext, mockModelAdapterFactory, adapterImplementations, null, null);
+ return new ModelPackageBundleListener(
+ mockBundleContext, mockModelAdapterFactory, adapterImplementations, null, null);
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/MultipleInjectorTest.java b/src/test/java/org/apache/sling/models/impl/MultipleInjectorTest.java
index 64da4c8..2ac3a01 100644
--- a/src/test/java/org/apache/sling/models/impl/MultipleInjectorTest.java
+++ b/src/test/java/org/apache/sling/models/impl/MultipleInjectorTest.java
@@ -1,27 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.lenient;
-import static org.mockito.Mockito.when;
-
import javax.inject.Inject;
import org.apache.sling.api.SlingHttpServletRequest;
@@ -38,6 +34,12 @@
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class MultipleInjectorTest {
@@ -103,7 +105,7 @@
assertNull(obj);
}
- @Test(expected=ModelClassException.class)
+ @Test(expected = ModelClassException.class)
public void testInjectorWithInvalidSourceWithException() {
factory.createModel(request, ForTwoInjectorsWithInvalidSource.class);
}
@@ -113,7 +115,6 @@
@Inject
private String firstAttribute;
-
}
@Model(adaptables = SlingHttpServletRequest.class)
@@ -122,7 +123,6 @@
@Inject
@Source("request-attributes")
private String firstAttribute;
-
}
@Model(adaptables = SlingHttpServletRequest.class)
@@ -131,7 +131,5 @@
@Inject
@Source("this-is-an-invalid-source")
private String firstAttribute;
-
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/OSGiInjectionTest.java b/src/test/java/org/apache/sling/models/impl/OSGiInjectionTest.java
index 044b7c6..60f1b16 100644
--- a/src/test/java/org/apache/sling/models/impl/OSGiInjectionTest.java
+++ b/src/test/java/org/apache/sling/models/impl/OSGiInjectionTest.java
@@ -1,33 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.lenient;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-
import java.util.Arrays;
import java.util.Dictionary;
@@ -54,6 +44,18 @@
import org.osgi.framework.BundleListener;
import org.osgi.framework.ServiceReference;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class OSGiInjectionTest {
private ModelAdapterFactory factory;
@@ -75,16 +77,26 @@
factory.bindInjector(injectorFactory, new ServicePropertiesMap(1, 1));
bindings.setSling(helper);
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(SimpleOSGiModel.class, ListOSGiModel.class, RequestOSGiModel.class, ArrayOSGiModel.class, SetOSGiModel.class, OptionalListOSGiModel.class, org.apache.sling.models.testmodels.classes.constructorinjection.ListOSGiModel.class, org.apache.sling.models.testmodels.classes.constructorinjection.SimpleOSGiModel.class, CollectionOSGiModel.class, OptionalArrayOSGiModel.class);
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ SimpleOSGiModel.class,
+ ListOSGiModel.class,
+ RequestOSGiModel.class,
+ ArrayOSGiModel.class,
+ SetOSGiModel.class,
+ OptionalListOSGiModel.class,
+ org.apache.sling.models.testmodels.classes.constructorinjection.ListOSGiModel.class,
+ org.apache.sling.models.testmodels.classes.constructorinjection.SimpleOSGiModel.class,
+ CollectionOSGiModel.class,
+ OptionalArrayOSGiModel.class);
}
@Test
- @SuppressWarnings({ "unchecked", "null" })
+ @SuppressWarnings({"unchecked", "null"})
public void testSimpleOSGiModelField() throws Exception {
ServiceReference ref = mock(ServiceReference.class);
ServiceInterface service = mock(ServiceInterface.class);
- when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null)).thenReturn(
- new ServiceReference[] { ref });
+ when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null))
+ .thenReturn(new ServiceReference[] {ref});
when(bundleContext.getService(ref)).thenReturn(service);
Resource res = mock(Resource.class);
@@ -98,7 +110,7 @@
}
@Test
- @SuppressWarnings({ "unchecked", "null" })
+ @SuppressWarnings({"unchecked", "null"})
public void testListOSGiModelField() throws Exception {
ServiceReference ref1 = mock(ServiceReference.class);
ServiceInterface service1 = mock(ServiceInterface.class);
@@ -107,8 +119,8 @@
ServiceInterface service2 = mock(ServiceInterface.class);
when(bundleContext.getService(ref2)).thenReturn(service2);
- when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null)).thenReturn(
- new ServiceReference[] { ref1, ref2 });
+ when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null))
+ .thenReturn(new ServiceReference[] {ref1, ref2});
Resource res = mock(Resource.class);
@@ -123,7 +135,7 @@
}
@Test
- @SuppressWarnings({ "unchecked", "null" })
+ @SuppressWarnings({"unchecked", "null"})
public void testArrayOSGiModelField() throws Exception {
ServiceReference ref1 = mock(ServiceReference.class);
ServiceInterface service1 = mock(ServiceInterface.class);
@@ -132,8 +144,8 @@
ServiceInterface service2 = mock(ServiceInterface.class);
when(bundleContext.getService(ref2)).thenReturn(service2);
- when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null)).thenReturn(
- new ServiceReference[] { ref1, ref2 });
+ when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null))
+ .thenReturn(new ServiceReference[] {ref1, ref2});
Resource res = mock(Resource.class);
@@ -173,7 +185,7 @@
}
@Test
- @SuppressWarnings({ "unchecked", "null" })
+ @SuppressWarnings({"unchecked", "null"})
public void testCollectionOSGiModelField() throws Exception {
ServiceReference ref1 = mock(ServiceReference.class);
ServiceInterface service1 = mock(ServiceInterface.class);
@@ -182,8 +194,8 @@
ServiceInterface service2 = mock(ServiceInterface.class);
when(bundleContext.getService(ref2)).thenReturn(service2);
- when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null)).thenReturn(
- new ServiceReference[] { ref1, ref2 });
+ when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null))
+ .thenReturn(new ServiceReference[] {ref1, ref2});
Resource res = mock(Resource.class);
@@ -198,7 +210,7 @@
}
@Test
- @SuppressWarnings({ "unused", "unchecked", "null" })
+ @SuppressWarnings({"unused", "unchecked", "null"})
public void testSetOSGiModelField() throws Exception {
ServiceReference ref1 = mock(ServiceReference.class);
ServiceInterface service1 = mock(ServiceInterface.class);
@@ -207,8 +219,9 @@
ServiceInterface service2 = mock(ServiceInterface.class);
lenient().when(bundleContext.getService(ref2)).thenReturn(service2);
- lenient().when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null)).thenReturn(
- new ServiceReference[] { ref1, ref2 });
+ lenient()
+ .when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null))
+ .thenReturn(new ServiceReference[] {ref1, ref2});
Resource res = mock(Resource.class);
@@ -224,18 +237,18 @@
}
@Test
- @SuppressWarnings({ "unchecked", "null" })
+ @SuppressWarnings({"unchecked", "null"})
public void testSimpleOSGiModelConstructor() throws Exception {
ServiceReference ref = mock(ServiceReference.class);
ServiceInterface service = mock(ServiceInterface.class);
- when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null)).thenReturn(
- new ServiceReference[] { ref });
+ when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null))
+ .thenReturn(new ServiceReference[] {ref});
when(bundleContext.getService(ref)).thenReturn(service);
Resource res = mock(Resource.class);
- org.apache.sling.models.testmodels.classes.constructorinjection.SimpleOSGiModel model
- = factory.getAdapter(res, org.apache.sling.models.testmodels.classes.constructorinjection.SimpleOSGiModel.class);
+ org.apache.sling.models.testmodels.classes.constructorinjection.SimpleOSGiModel model = factory.getAdapter(
+ res, org.apache.sling.models.testmodels.classes.constructorinjection.SimpleOSGiModel.class);
assertNotNull(model);
assertNotNull(model.getService());
assertEquals(service, model.getService());
@@ -244,7 +257,7 @@
}
@Test
- @SuppressWarnings({ "unchecked", "null" })
+ @SuppressWarnings({"unchecked", "null"})
public void testListOSGiModelConstructor() throws Exception {
ServiceReference ref1 = mock(ServiceReference.class);
ServiceInterface service1 = mock(ServiceInterface.class);
@@ -253,13 +266,13 @@
ServiceInterface service2 = mock(ServiceInterface.class);
when(bundleContext.getService(ref2)).thenReturn(service2);
- when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null)).thenReturn(
- new ServiceReference[] { ref1, ref2 });
+ when(bundleContext.getServiceReferences(ServiceInterface.class.getName(), null))
+ .thenReturn(new ServiceReference[] {ref1, ref2});
Resource res = mock(Resource.class);
- org.apache.sling.models.testmodels.classes.constructorinjection.ListOSGiModel model
- = factory.getAdapter(res, org.apache.sling.models.testmodels.classes.constructorinjection.ListOSGiModel.class);
+ org.apache.sling.models.testmodels.classes.constructorinjection.ListOSGiModel model = factory.getAdapter(
+ res, org.apache.sling.models.testmodels.classes.constructorinjection.ListOSGiModel.class);
assertNotNull(model);
assertNotNull(model.getServices());
// the order on those is non deterministic as the ServiceReference.compareTo() is always returning 0
@@ -268,5 +281,4 @@
verifyNoMoreInteractions(res);
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/OptionalObjectsTest.java b/src/test/java/org/apache/sling/models/impl/OptionalObjectsTest.java
index 250714d..6e3a610 100644
--- a/src/test/java/org/apache/sling/models/impl/OptionalObjectsTest.java
+++ b/src/test/java/org/apache/sling/models/impl/OptionalObjectsTest.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
@@ -40,6 +42,7 @@
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
+
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
@@ -73,24 +76,23 @@
ChildResourceInjector childResourceInjector = new ChildResourceInjector();
RequestAttributeInjector requestAttributeInjector = new RequestAttributeInjector();
- factory.bindInjector(bindingsInjector,
- Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 1L));
- factory.bindInjector(valueMapInjector,
- Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 2L));
- factory.bindInjector(childResourceInjector,
- Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 3L));
- factory.bindInjector(requestAttributeInjector,
- Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 4L));
+ factory.bindInjector(bindingsInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 1L));
+ factory.bindInjector(valueMapInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 2L));
+ factory.bindInjector(childResourceInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 3L));
+ factory.bindInjector(
+ requestAttributeInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 4L));
factory.bindInjector(osgiInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 5L));
- factory.bindStaticInjectAnnotationProcessorFactory(bindingsInjector,
- Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 1L));
- factory.injectAnnotationProcessorFactories = Collections.<InjectAnnotationProcessorFactory>singletonList(valueMapInjector);
- factory.injectAnnotationProcessorFactories2 = Collections.<InjectAnnotationProcessorFactory2>singletonList(childResourceInjector);
- factory.bindStaticInjectAnnotationProcessorFactory(requestAttributeInjector,
- Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 4L));
- factory.bindStaticInjectAnnotationProcessorFactory(osgiInjector,
- Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 5L));
+ factory.bindStaticInjectAnnotationProcessorFactory(
+ bindingsInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 1L));
+ factory.injectAnnotationProcessorFactories =
+ Collections.<InjectAnnotationProcessorFactory>singletonList(valueMapInjector);
+ factory.injectAnnotationProcessorFactories2 =
+ Collections.<InjectAnnotationProcessorFactory2>singletonList(childResourceInjector);
+ factory.bindStaticInjectAnnotationProcessorFactory(
+ requestAttributeInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 4L));
+ factory.bindStaticInjectAnnotationProcessorFactory(
+ osgiInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 5L));
factory.bindViaProvider(new BeanPropertyViaProvider(), null);
SlingBindings bindings = new SlingBindings();
@@ -98,7 +100,6 @@
Mockito.when(request.getAttribute(SlingBindings.class.getName())).thenReturn(bindings);
factory.adapterImplementations.addClassesAsAdapterAndImplementation(OptionalObjectsModel.class);
-
}
@Test
@@ -118,8 +119,8 @@
Resource res = mock(Resource.class);
when(res.adaptTo(ValueMap.class)).thenReturn(new ValueMapDecorator(map));
- org.apache.sling.models.testmodels.classes.OptionalObjectsModel model = factory.getAdapter(res,
- OptionalObjectsModel.class);
+ org.apache.sling.models.testmodels.classes.OptionalObjectsModel model =
+ factory.getAdapter(res, OptionalObjectsModel.class);
assertNotNull(model);
assertEquals(Optional.of("foo bar baz"), model.getOptionalString());
@@ -157,10 +158,10 @@
public void testFieldInjectionListsAndArrays() {
Map<String, Object> map = new HashMap<>();
- map.put("intList", new Integer[]{1, 2, 9, 8});
- map.put("stringList", new String[]{"hello", "world"});
+ map.put("intList", new Integer[] {1, 2, 9, 8});
+ map.put("stringList", new String[] {"hello", "world"});
map.put("optionalList", Arrays.asList("foo", "bar", "baz"));
- map.put("optionalArray", new String[]{"qux", "quux"});
+ map.put("optionalArray", new String[] {"qux", "quux"});
ValueMap vm = new ValueMapDecorator(map);
Resource res = mock(Resource.class);
@@ -215,8 +216,7 @@
public void testFieldInjectionsOSGiService() throws InvalidSyntaxException {
ServiceReference ref = mock(ServiceReference.class);
Logger log = mock(Logger.class);
- when(bundleContext.getServiceReferences(Logger.class.getName(), null)).thenReturn(
- new ServiceReference[]{ref});
+ when(bundleContext.getServiceReferences(Logger.class.getName(), null)).thenReturn(new ServiceReference[] {ref});
when(bundleContext.getService(ref)).thenReturn(log);
OptionalObjectsModel model = factory.getAdapter(request, OptionalObjectsModel.class);
diff --git a/src/test/java/org/apache/sling/models/impl/OptionalPrimitivesTest.java b/src/test/java/org/apache/sling/models/impl/OptionalPrimitivesTest.java
index c98e954..6307793 100644
--- a/src/test/java/org/apache/sling/models/impl/OptionalPrimitivesTest.java
+++ b/src/test/java/org/apache/sling/models/impl/OptionalPrimitivesTest.java
@@ -1,28 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.lenient;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.models.impl.injectors.ChildResourceInjector;
@@ -32,6 +27,13 @@
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
/**
* Validates that @Optional annotations works with primitive values which do not support null
*/
@@ -45,7 +47,10 @@
factory = AdapterFactoryTest.createModelAdapterFactory();
factory.bindInjector(new ValueMapInjector(), new ServicePropertiesMap(2, 2));
factory.bindInjector(new ChildResourceInjector(), new ServicePropertiesMap(1, 1));
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(org.apache.sling.models.testmodels.classes.OptionalPrimitivesModel.class, org.apache.sling.models.testmodels.interfaces.OptionalPrimitivesModel.class, org.apache.sling.models.testmodels.classes.constructorinjection.OptionalPrimitivesModel.class);
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ org.apache.sling.models.testmodels.classes.OptionalPrimitivesModel.class,
+ org.apache.sling.models.testmodels.interfaces.OptionalPrimitivesModel.class,
+ org.apache.sling.models.testmodels.classes.constructorinjection.OptionalPrimitivesModel.class);
}
@Test
@@ -55,72 +60,8 @@
Resource res = mock(Resource.class);
when(res.adaptTo(ValueMap.class)).thenReturn(vm);
- org.apache.sling.models.testmodels.classes.OptionalPrimitivesModel model
- = factory.getAdapter(res, org.apache.sling.models.testmodels.classes.OptionalPrimitivesModel.class);
- assertNotNull(model);
-
- // make sure primitives are initialized with initial value
- assertEquals(0, model.getByteValue());
- assertEquals(0, model.getShortValue());
- assertEquals(0, model.getIntValue());
- assertEquals(0L, model.getLongValue());
- assertEquals(0.0f, model.getFloatValue(), 0.00001d);
- assertEquals(0.0d, model.getDoubleValue(), 0.00001d);
- assertEquals('\u0000', model.getCharValue());
- assertEquals(false, model.getBooleanValue());
-
- // make sure object wrapper of primitives are null
- assertNull(model.getByteObjectValue());
- assertNull(model.getShortObjectValue());
- assertNull(model.getIntObjectValue());
- assertNull(model.getLongObjectValue());
- assertNull(model.getFloatObjectValue());
- assertNull(model.getDoubleObjectValue());
- assertNull(model.getCharObjectValue());
- assertNull(model.getBooleanObjectValue());
-}
-
- @Test
- public void testConstructorInjection() {
- ValueMap vm = ValueMap.EMPTY;
-
- Resource res = mock(Resource.class);
- lenient().when(res.adaptTo(ValueMap.class)).thenReturn(vm);
-
- org.apache.sling.models.testmodels.classes.constructorinjection.OptionalPrimitivesModel model
- = factory.getAdapter(res, org.apache.sling.models.testmodels.classes.constructorinjection.OptionalPrimitivesModel.class);
- assertNotNull(model);
-
- // make sure primitives are initialized with initial value
- assertEquals(0, model.getByteValue());
- assertEquals(0, model.getShortValue());
- assertEquals(0, model.getIntValue());
- assertEquals(0L, model.getLongValue());
- assertEquals(0.0f, model.getFloatValue(), 0.00001d);
- assertEquals(0.0d, model.getDoubleValue(), 0.00001d);
- assertEquals('\u0000', model.getCharValue());
- assertEquals(false, model.getBooleanValue());
-
- // make sure object wrapper of primitives are null
- assertNull(model.getByteObjectValue());
- assertNull(model.getShortObjectValue());
- assertNull(model.getIntObjectValue());
- assertNull(model.getLongObjectValue());
- assertNull(model.getFloatObjectValue());
- assertNull(model.getDoubleObjectValue());
- assertNull(model.getCharObjectValue());
- assertNull(model.getBooleanObjectValue());
-}
-
- @Test
- public void testFieldInjectionInterface() {
- ValueMap vm = ValueMap.EMPTY;
-
- Resource res = mock(Resource.class);
- lenient().when(res.adaptTo(ValueMap.class)).thenReturn(vm);
-
- org.apache.sling.models.testmodels.interfaces.OptionalPrimitivesModel model
- = factory.getAdapter(res, org.apache.sling.models.testmodels.interfaces.OptionalPrimitivesModel.class);
+ org.apache.sling.models.testmodels.classes.OptionalPrimitivesModel model =
+ factory.getAdapter(res, org.apache.sling.models.testmodels.classes.OptionalPrimitivesModel.class);
assertNotNull(model);
// make sure primitives are initialized with initial value
@@ -144,4 +85,69 @@
assertNull(model.getBooleanObjectValue());
}
+ @Test
+ public void testConstructorInjection() {
+ ValueMap vm = ValueMap.EMPTY;
+
+ Resource res = mock(Resource.class);
+ lenient().when(res.adaptTo(ValueMap.class)).thenReturn(vm);
+
+ org.apache.sling.models.testmodels.classes.constructorinjection.OptionalPrimitivesModel model =
+ factory.getAdapter(
+ res,
+ org.apache.sling.models.testmodels.classes.constructorinjection.OptionalPrimitivesModel.class);
+ assertNotNull(model);
+
+ // make sure primitives are initialized with initial value
+ assertEquals(0, model.getByteValue());
+ assertEquals(0, model.getShortValue());
+ assertEquals(0, model.getIntValue());
+ assertEquals(0L, model.getLongValue());
+ assertEquals(0.0f, model.getFloatValue(), 0.00001d);
+ assertEquals(0.0d, model.getDoubleValue(), 0.00001d);
+ assertEquals('\u0000', model.getCharValue());
+ assertEquals(false, model.getBooleanValue());
+
+ // make sure object wrapper of primitives are null
+ assertNull(model.getByteObjectValue());
+ assertNull(model.getShortObjectValue());
+ assertNull(model.getIntObjectValue());
+ assertNull(model.getLongObjectValue());
+ assertNull(model.getFloatObjectValue());
+ assertNull(model.getDoubleObjectValue());
+ assertNull(model.getCharObjectValue());
+ assertNull(model.getBooleanObjectValue());
+ }
+
+ @Test
+ public void testFieldInjectionInterface() {
+ ValueMap vm = ValueMap.EMPTY;
+
+ Resource res = mock(Resource.class);
+ lenient().when(res.adaptTo(ValueMap.class)).thenReturn(vm);
+
+ org.apache.sling.models.testmodels.interfaces.OptionalPrimitivesModel model =
+ factory.getAdapter(res, org.apache.sling.models.testmodels.interfaces.OptionalPrimitivesModel.class);
+ assertNotNull(model);
+
+ // make sure primitives are initialized with initial value
+ assertEquals(0, model.getByteValue());
+ assertEquals(0, model.getShortValue());
+ assertEquals(0, model.getIntValue());
+ assertEquals(0L, model.getLongValue());
+ assertEquals(0.0f, model.getFloatValue(), 0.00001d);
+ assertEquals(0.0d, model.getDoubleValue(), 0.00001d);
+ assertEquals('\u0000', model.getCharValue());
+ assertEquals(false, model.getBooleanValue());
+
+ // make sure object wrapper of primitives are null
+ assertNull(model.getByteObjectValue());
+ assertNull(model.getShortObjectValue());
+ assertNull(model.getIntObjectValue());
+ assertNull(model.getLongObjectValue());
+ assertNull(model.getFloatObjectValue());
+ assertNull(model.getDoubleObjectValue());
+ assertNull(model.getCharObjectValue());
+ assertNull(model.getBooleanObjectValue());
+ }
}
diff --git a/src/test/java/org/apache/sling/models/impl/ParameterizedTypeFromRequestAttributeTest.java b/src/test/java/org/apache/sling/models/impl/ParameterizedTypeFromRequestAttributeTest.java
index 6564e7b..377815c 100644
--- a/src/test/java/org/apache/sling/models/impl/ParameterizedTypeFromRequestAttributeTest.java
+++ b/src/test/java/org/apache/sling/models/impl/ParameterizedTypeFromRequestAttributeTest.java
@@ -18,15 +18,11 @@
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.when;
+import javax.inject.Inject;
import java.util.Collections;
import java.util.Iterator;
-import javax.inject.Inject;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
@@ -37,6 +33,10 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class ParameterizedTypeFromRequestAttributeTest {
private ModelAdapterFactory factory;
@@ -55,7 +55,7 @@
@Test
public void test() {
- Iterator<Resource> it = Collections.<Resource> emptySet().iterator();
+ Iterator<Resource> it = Collections.<Resource>emptySet().iterator();
when(request.getAttribute("someResources")).thenReturn(it);
TestModel model = factory.getAdapter(request, TestModel.class);
diff --git a/src/test/java/org/apache/sling/models/impl/PostConstructTest.java b/src/test/java/org/apache/sling/models/impl/PostConstructTest.java
index a6eaeb3..e3c7af4 100644
--- a/src/test/java/org/apache/sling/models/impl/PostConstructTest.java
+++ b/src/test/java/org/apache/sling/models/impl/PostConstructTest.java
@@ -1,27 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.factory.PostConstructException;
import org.apache.sling.models.testmodels.classes.FailingPostConstructModel;
@@ -35,6 +31,12 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
@RunWith(MockitoJUnitRunner.class)
public class PostConstructTest {
@@ -47,7 +49,12 @@
public void setup() {
factory = AdapterFactoryTest.createModelAdapterFactory();
// no injectors are necessary
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(SubClass.class, SubClassOverriddenPostConstruct.class, FailingPostConstructModel.class, FalsePostConstructModel.class, TruePostConstructModel.class);
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ SubClass.class,
+ SubClassOverriddenPostConstruct.class,
+ FailingPostConstructModel.class,
+ FalsePostConstructModel.class,
+ TruePostConstructModel.class);
}
@Test
@@ -60,8 +67,12 @@
@Test
public void testOverriddenPostConstruct() {
SubClassOverriddenPostConstruct sc = factory.getAdapter(resource, SubClassOverriddenPostConstruct.class);
- assertEquals("Post construct not called exactly one time in sub class!", 1, sc.getPostConstructorCalledCounter());
- assertEquals("Post construct was called on super class although overridden in sub class", 0, sc.getPostConstructCalledTimestampInSuper());
+ assertEquals(
+ "Post construct not called exactly one time in sub class!", 1, sc.getPostConstructorCalledCounter());
+ assertEquals(
+ "Post construct was called on super class although overridden in sub class",
+ 0,
+ sc.getPostConstructCalledTimestampInSuper());
}
@Test
@@ -88,7 +99,9 @@
}
public void testPostConstructMethodWhichReturnsFalseInternalCreateModel() {
- assertSame(Result.POST_CONSTRUCT_PREVENTED_MODEL_CONSTRUCTION, factory.internalCreateModel(resource, FalsePostConstructModel.class));
+ assertSame(
+ Result.POST_CONSTRUCT_PREVENTED_MODEL_CONSTRUCTION,
+ factory.internalCreateModel(resource, FalsePostConstructModel.class));
}
@Test
diff --git a/src/test/java/org/apache/sling/models/impl/RequestDisposalTest.java b/src/test/java/org/apache/sling/models/impl/RequestDisposalTest.java
index 61e3e0f..e754de6 100644
--- a/src/test/java/org/apache/sling/models/impl/RequestDisposalTest.java
+++ b/src/test/java/org/apache/sling/models/impl/RequestDisposalTest.java
@@ -1,27 +1,26 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.when;
+import javax.inject.Inject;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequestEvent;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Type;
@@ -30,10 +29,6 @@
import java.util.Map;
import java.util.Set;
-import javax.inject.Inject;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletRequestEvent;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper;
@@ -51,6 +46,13 @@
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class RequestDisposalTest {
@Mock
@@ -76,12 +78,16 @@
doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) {
- attributes.put((String) invocation.getArguments()[0], invocation.getArguments()[1]);
- return null;
- }
- }).when(request).setAttribute(any(String.class), any());
+ @Override
+ public Void answer(InvocationOnMock invocation) {
+ attributes.put(
+ (String) invocation.getArguments()[0],
+ invocation.getArguments()[1]);
+ return null;
+ }
+ })
+ .when(request)
+ .setAttribute(any(String.class), any());
when(request.getAttribute(any(String.class))).then(new Answer<Object>() {
@@ -100,7 +106,8 @@
factory.requestInitialized(new ServletRequestEvent(servletContext, destroyedRequest));
// but adapt from a wrapper of a wrapper of that wrapper
- SlingHttpServletRequest adaptableRequest = new SlingHttpServletRequestWrapper(new SlingHttpServletRequestWrapper(destroyedRequest));
+ SlingHttpServletRequest adaptableRequest =
+ new SlingHttpServletRequestWrapper(new SlingHttpServletRequestWrapper(destroyedRequest));
TestModel model = factory.getAdapter(adaptableRequest, TestModel.class);
assertEquals("teststring", model.testString);
@@ -119,7 +126,8 @@
factory.requestInitialized(new ServletRequestEvent(servletContext, destroyedRequest));
// but adapt from a wrapper of a wrapper of that wrapper
- SlingHttpServletRequest adaptableRequest = new SlingHttpServletRequestWrapper(new SlingHttpServletRequestWrapper(destroyedRequest));
+ SlingHttpServletRequest adaptableRequest =
+ new SlingHttpServletRequestWrapper(new SlingHttpServletRequestWrapper(destroyedRequest));
TestModel model = factory.getAdapter(adaptableRequest, TestModel.class);
assertEquals("teststring", model.testString);
@@ -140,7 +148,8 @@
SlingHttpServletRequest destroyedRequest = new SlingHttpServletRequestWrapper(request);
// but adapt from a wrapper of a wrapper of that wrapper
- SlingHttpServletRequest adaptableRequest = new SlingHttpServletRequestWrapper(new SlingHttpServletRequestWrapper(destroyedRequest));
+ SlingHttpServletRequest adaptableRequest =
+ new SlingHttpServletRequestWrapper(new SlingHttpServletRequestWrapper(destroyedRequest));
TestModel model = factory.getAdapter(adaptableRequest, TestModel.class);
assertEquals("teststring", model.testString);
@@ -169,7 +178,6 @@
@Inject
public String testString;
-
}
private class DisposedInjector implements Injector {
@@ -181,7 +189,12 @@
@Nullable
@Override
- public Object getValue(@NotNull Object o, String s, @NotNull Type type, @NotNull AnnotatedElement annotatedElement, @NotNull DisposalCallbackRegistry disposalCallbackRegistry) {
+ public Object getValue(
+ @NotNull Object o,
+ String s,
+ @NotNull Type type,
+ @NotNull AnnotatedElement annotatedElement,
+ @NotNull DisposalCallbackRegistry disposalCallbackRegistry) {
TestDisposalCallback callback = new TestDisposalCallback();
callbacks.add(callback);
disposalCallbackRegistry.addDisposalCallback(callback);
@@ -201,6 +214,4 @@
return disposed;
}
}
-
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/RequestInjectionTest.java b/src/test/java/org/apache/sling/models/impl/RequestInjectionTest.java
index 41923a0..c5f317a 100644
--- a/src/test/java/org/apache/sling/models/impl/RequestInjectionTest.java
+++ b/src/test/java/org/apache/sling/models/impl/RequestInjectionTest.java
@@ -1,27 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.times;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.scripting.SlingBindings;
import org.apache.sling.api.scripting.SlingScriptHelper;
@@ -34,6 +30,12 @@
import org.mockito.junit.MockitoJUnitRunner;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class RequestInjectionTest {
@@ -54,7 +56,9 @@
factory = AdapterFactoryTest.createModelAdapterFactory();
factory.bindInjector(new BindingsInjector(), new ServicePropertiesMap(1, 1));
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(BindingsModel.class, org.apache.sling.models.testmodels.classes.constructorinjection.BindingsModel.class);
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ BindingsModel.class,
+ org.apache.sling.models.testmodels.classes.constructorinjection.BindingsModel.class);
}
@Test
@@ -68,13 +72,12 @@
@Test
public void testNamedInjectionConstructor() {
- org.apache.sling.models.testmodels.classes.constructorinjection.BindingsModel model
- = factory.getAdapter(request, org.apache.sling.models.testmodels.classes.constructorinjection.BindingsModel.class);
+ org.apache.sling.models.testmodels.classes.constructorinjection.BindingsModel model = factory.getAdapter(
+ request, org.apache.sling.models.testmodels.classes.constructorinjection.BindingsModel.class);
assertNotNull(model.getSling());
assertEquals(sling, model.getSling());
assertEquals("test", model.getLog().getName());
verify(request, times(1)).getAttribute(SlingBindings.class.getName());
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/RequestWrapperTest.java b/src/test/java/org/apache/sling/models/impl/RequestWrapperTest.java
index 04bef4d..0a1a6ff 100644
--- a/src/test/java/org/apache/sling/models/impl/RequestWrapperTest.java
+++ b/src/test/java/org/apache/sling/models/impl/RequestWrapperTest.java
@@ -1,34 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.argThat;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.Collections;
-
import javax.script.Bindings;
import javax.script.ScriptEngineFactory;
+import java.util.Collections;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.adapter.AdapterManager;
import org.apache.sling.api.resource.Resource;
@@ -43,6 +37,14 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class RequestWrapperTest {
@@ -69,14 +71,16 @@
factory = AdapterFactoryTest.createModelAdapterFactory();
factory.bindingsValuesProvidersByContext = bindingsValuesProvidersByContext;
factory.adapterManager = adapterManager;
- when(bindingsValuesProvidersByContext.getBindingsValuesProviders(any(ScriptEngineFactory.class), eq(BindingsValuesProvider.DEFAULT_CONTEXT))).
- thenReturn(Collections.singleton(bindingsValuesProvider));
+ when(bindingsValuesProvidersByContext.getBindingsValuesProviders(
+ any(ScriptEngineFactory.class), eq(BindingsValuesProvider.DEFAULT_CONTEXT)))
+ .thenReturn(Collections.singleton(bindingsValuesProvider));
}
@Test
public void testWrapper() {
Target expected = new Target();
- when(adapterManager.getAdapter(any(SlingHttpServletRequest.class), eq(Target.class))).thenReturn(expected);
+ when(adapterManager.getAdapter(any(SlingHttpServletRequest.class), eq(Target.class)))
+ .thenReturn(expected);
Target actual = factory.getModelFromWrappedRequest(request, resource, Target.class);
assertEquals(expected, actual);
@@ -103,8 +107,5 @@
};
}
- class Target {
-
- }
-
+ class Target {}
}
diff --git a/src/test/java/org/apache/sling/models/impl/ResourceModelClassesTest.java b/src/test/java/org/apache/sling/models/impl/ResourceModelClassesTest.java
index f802baf..42488c2 100644
--- a/src/test/java/org/apache/sling/models/impl/ResourceModelClassesTest.java
+++ b/src/test/java/org/apache/sling/models/impl/ResourceModelClassesTest.java
@@ -1,32 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.lenient;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collections;
@@ -60,6 +51,17 @@
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
@SuppressWarnings("deprecation")
@RunWith(MockitoJUnitRunner.class)
public class ResourceModelClassesTest {
@@ -73,8 +75,10 @@
factory.bindInjector(valueMapInjector, new ServicePropertiesMap(2, 2));
factory.bindInjector(new ChildResourceInjector(), new ServicePropertiesMap(1, 1));
- factory.injectAnnotationProcessorFactories = factory.injectAnnotationProcessorFactories = Collections.<InjectAnnotationProcessorFactory>singletonList(new ValueMapInjector());
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(SimplePropertyModel.class,
+ factory.injectAnnotationProcessorFactories = factory.injectAnnotationProcessorFactories =
+ Collections.<InjectAnnotationProcessorFactory>singletonList(new ValueMapInjector());
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ SimplePropertyModel.class,
ArrayWrappersModel.class,
ResourceModelWithRequiredField.class,
ChildValueMapModel.class,
@@ -94,7 +98,7 @@
map.put("first", "first-value");
map.put("third", "third-value");
map.put("intProperty", new Integer(3));
- map.put("arrayProperty", new String[] { "three", "four" });
+ map.put("arrayProperty", new String[] {"three", "four"});
ValueMap vm = new ValueMapDecorator(map);
Resource res = mock(Resource.class);
@@ -119,7 +123,7 @@
@Test
public void testArrayPrimitivesModel() {
Map<String, Object> map = new HashMap<>();
- map.put("intArray", new int[] { 1, 2, 9, 8 });
+ map.put("intArray", new int[] {1, 2, 9, 8});
map.put("secondIntArray", new Integer[] {1, 2, 9, 8});
ValueMap vm = new ValueMapDecorator(map);
@@ -194,12 +198,12 @@
assertNotNull(model);
assertEquals(Arrays.asList("v1", "v2"), model.getStringList());
- assertEquals(Arrays.asList(1,2,3), model.getIntList());
- assertEquals(Arrays.asList(1L,2L), model.getLongList());
- assertEquals(Arrays.asList(true,false), model.getBooleanList());
- assertEquals(Arrays.asList((short)1), model.getShortList());
- assertEquals(Arrays.asList(1.1f,1.2f), model.getFloatList());
- assertEquals(Arrays.asList(1.1d,1.2d,1.3d), model.getDoubleList());
+ assertEquals(Arrays.asList(1, 2, 3), model.getIntList());
+ assertEquals(Arrays.asList(1L, 2L), model.getLongList());
+ assertEquals(Arrays.asList(true, false), model.getBooleanList());
+ assertEquals(Arrays.asList((short) 1), model.getShortList());
+ assertEquals(Arrays.asList(1.1f, 1.2f), model.getFloatList());
+ assertEquals(Arrays.asList(1.1d, 1.2d, 1.3d), model.getDoubleList());
}
@Test
@@ -213,11 +217,11 @@
CollectionDefaultsModel model = factory.getAdapter(res, CollectionDefaultsModel.class);
assertNotNull(model);
- assertEquals(Arrays.asList(1,2,3), model.getIntCollection());
+ assertEquals(Arrays.asList(1, 2, 3), model.getIntCollection());
assertEquals(Arrays.asList("v1", "v2"), model.getStringCollection());
}
- @SuppressWarnings({ "unused", "null" })
+ @SuppressWarnings({"unused", "null"})
@Test
public void testRequiredPropertyModel() {
Map<String, Object> map = new HashMap<>();
@@ -248,7 +252,9 @@
try {
factory.createModel(res, ResourceModelWithRequiredField.class);
} catch (MissingElementsException e) {
- assertEquals("required", ((Field) e.getMissingElements().iterator().next().getElement()).getName());
+ assertEquals(
+ "required",
+ ((Field) e.getMissingElements().iterator().next().getElement()).getName());
thrown = true;
}
assertTrue(thrown);
@@ -256,7 +262,7 @@
verify(vm).get("required", String.class);
}
- @SuppressWarnings({ "unused", "null" })
+ @SuppressWarnings({"unused", "null"})
@Test
public void testRequiredPropertyMissingModelOptionalStrategy() {
Map<String, Object> map = new HashMap<>();
@@ -266,7 +272,8 @@
Resource res = mock(Resource.class);
when(res.adaptTo(ValueMap.class)).thenReturn(vm);
- ResourceModelWithRequiredFieldOptionalStrategy model = factory.getAdapter(res, ResourceModelWithRequiredFieldOptionalStrategy.class);
+ ResourceModelWithRequiredFieldOptionalStrategy model =
+ factory.getAdapter(res, ResourceModelWithRequiredFieldOptionalStrategy.class);
assertNull(model);
verify(vm).get("optional1", String.class);
@@ -284,7 +291,8 @@
Resource res = mock(Resource.class);
when(res.adaptTo(ValueMap.class)).thenReturn(vm);
- ResourceModelWithRequiredFieldOptionalStrategy model = factory.getAdapter(res, ResourceModelWithRequiredFieldOptionalStrategy.class);
+ ResourceModelWithRequiredFieldOptionalStrategy model =
+ factory.getAdapter(res, ResourceModelWithRequiredFieldOptionalStrategy.class);
assertNotNull(model);
assertEquals("required value", model.getRequired1());
assertEquals("required value", model.getRequired2());
@@ -301,8 +309,10 @@
Resource firstGrandChild = mock(Resource.class);
Resource secondGrandChild = mock(Resource.class);
- when(secondChild.listChildren()).thenReturn(Arrays.asList(firstGrandChild, secondGrandChild).iterator());
- when(emptyChild.listChildren()).thenReturn(Collections.<Resource>emptySet().iterator());
+ when(secondChild.listChildren())
+ .thenReturn(Arrays.asList(firstGrandChild, secondGrandChild).iterator());
+ when(emptyChild.listChildren())
+ .thenReturn(Collections.<Resource>emptySet().iterator());
Resource res = mock(Resource.class);
when(res.getChild("firstChild")).thenReturn(child);
@@ -345,7 +355,8 @@
Object firstGrandChildValue = RandomStringUtils.randomAlphabetic(10);
ValueMap firstGrandChildMap = new ValueMapDecorator(Collections.singletonMap("property", firstGrandChildValue));
Object secondGrandChildValue = RandomStringUtils.randomAlphabetic(10);
- ValueMap secondGrandChildMap = new ValueMapDecorator(Collections.singletonMap("property", secondGrandChildValue));
+ ValueMap secondGrandChildMap =
+ new ValueMapDecorator(Collections.singletonMap("property", secondGrandChildValue));
final Resource firstGrandChild = mock(Resource.class);
lenient().when(firstGrandChild.adaptTo(ValueMap.class)).thenReturn(firstGrandChildMap);
@@ -356,10 +367,14 @@
lenient().when(secondGrandChild.adaptTo(ChildModel.class)).thenAnswer(new AdaptToChildModel());
Resource secondChild = mock(Resource.class);
- lenient().when(secondChild.listChildren()).thenReturn(Arrays.asList(firstGrandChild, secondGrandChild).iterator());
+ lenient()
+ .when(secondChild.listChildren())
+ .thenReturn(Arrays.asList(firstGrandChild, secondGrandChild).iterator());
Resource emptyChild = mock(Resource.class);
- lenient().when(emptyChild.listChildren()).thenReturn(Collections.<Resource>emptySet().iterator());
+ lenient()
+ .when(emptyChild.listChildren())
+ .thenReturn(Collections.<Resource>emptySet().iterator());
Resource res = mock(Resource.class);
lenient().when(res.getChild("firstChild")).thenReturn(firstChild);
@@ -385,5 +400,4 @@
return factory.getAdapter(invocation.getMock(), ChildModel.class);
}
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/ResourceModelConstructorTest.java b/src/test/java/org/apache/sling/models/impl/ResourceModelConstructorTest.java
index 55164b9..e382bc6 100644
--- a/src/test/java/org/apache/sling/models/impl/ResourceModelConstructorTest.java
+++ b/src/test/java/org/apache/sling/models/impl/ResourceModelConstructorTest.java
@@ -1,26 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.lenient;
-import static org.mockito.Mockito.mock;
-
import java.util.Arrays;
import java.util.Collections;
@@ -39,6 +36,11 @@
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.mock;
+
@RunWith(MockitoJUnitRunner.class)
public class ResourceModelConstructorTest {
@@ -64,7 +66,8 @@
Object firstGrandChildValue = RandomStringUtils.randomAlphabetic(10);
ValueMap firstGrandChildMap = new ValueMapDecorator(Collections.singletonMap("property", firstGrandChildValue));
Object secondGrandChildValue = RandomStringUtils.randomAlphabetic(10);
- ValueMap secondGrandChildMap = new ValueMapDecorator(Collections.singletonMap("property", secondGrandChildValue));
+ ValueMap secondGrandChildMap =
+ new ValueMapDecorator(Collections.singletonMap("property", secondGrandChildValue));
final Resource firstGrandChild = mock(Resource.class);
lenient().when(firstGrandChild.adaptTo(ValueMap.class)).thenReturn(firstGrandChildMap);
@@ -75,10 +78,14 @@
lenient().when(secondGrandChild.adaptTo(ChildModel.class)).thenAnswer(new AdaptToChildModel());
Resource secondChild = mock(Resource.class);
- lenient().when(secondChild.listChildren()).thenReturn(Arrays.asList(firstGrandChild, secondGrandChild).iterator());
+ lenient()
+ .when(secondChild.listChildren())
+ .thenReturn(Arrays.asList(firstGrandChild, secondGrandChild).iterator());
Resource emptyChild = mock(Resource.class);
- lenient().when(emptyChild.listChildren()).thenReturn(Collections.<Resource>emptySet().iterator());
+ lenient()
+ .when(emptyChild.listChildren())
+ .thenReturn(Collections.<Resource>emptySet().iterator());
Resource res = mock(Resource.class);
lenient().when(res.getChild("firstChild")).thenReturn(firstChild);
@@ -104,5 +111,4 @@
return factory.getAdapter(invocation.getMock(), ChildModel.class);
}
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/ResourceModelInterfacesTest.java b/src/test/java/org/apache/sling/models/impl/ResourceModelInterfacesTest.java
index 155aee9..aa5333a 100644
--- a/src/test/java/org/apache/sling/models/impl/ResourceModelInterfacesTest.java
+++ b/src/test/java/org/apache/sling/models/impl/ResourceModelInterfacesTest.java
@@ -1,32 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.lenient;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -51,6 +42,17 @@
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class ResourceModelInterfacesTest {
@@ -61,7 +63,13 @@
factory = AdapterFactoryTest.createModelAdapterFactory();
factory.bindInjector(new ValueMapInjector(), new ServicePropertiesMap(2, 2));
factory.bindInjector(new ChildResourceInjector(), new ServicePropertiesMap(1, 1));
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(SimplePropertyModel.class, ResourceModelWithRequiredField.class, ChildResourceModel.class, ChildValueMapModel.class, ParentModel.class, ChildModel.class);
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ SimplePropertyModel.class,
+ ResourceModelWithRequiredField.class,
+ ChildResourceModel.class,
+ ChildValueMapModel.class,
+ ParentModel.class,
+ ChildModel.class);
}
@Test
@@ -86,7 +94,7 @@
}
@Test
- @SuppressWarnings({ "unused", "null" })
+ @SuppressWarnings({"unused", "null"})
public void testRequiredPropertyModel() {
Map<String, Object> map = new HashMap<>();
map.put("first", "first-value");
@@ -142,7 +150,8 @@
Object firstGrandChildValue = RandomStringUtils.randomAlphabetic(10);
ValueMap firstGrandChildMap = new ValueMapDecorator(Collections.singletonMap("property", firstGrandChildValue));
Object secondGrandChildValue = RandomStringUtils.randomAlphabetic(10);
- ValueMap secondGrandChildMap = new ValueMapDecorator(Collections.singletonMap("property", secondGrandChildValue));
+ ValueMap secondGrandChildMap =
+ new ValueMapDecorator(Collections.singletonMap("property", secondGrandChildValue));
final Resource firstGrandChild = mock(Resource.class);
lenient().when(firstGrandChild.adaptTo(ValueMap.class)).thenReturn(firstGrandChildMap);
@@ -153,10 +162,14 @@
lenient().when(secondGrandChild.adaptTo(ChildModel.class)).thenAnswer(new AdaptToChildModel());
Resource secondChild = mock(Resource.class);
- lenient().when(secondChild.listChildren()).thenReturn(Arrays.asList(firstGrandChild, secondGrandChild).iterator());
+ lenient()
+ .when(secondChild.listChildren())
+ .thenReturn(Arrays.asList(firstGrandChild, secondGrandChild).iterator());
Resource emptyChild = mock(Resource.class);
- lenient().when(emptyChild.listChildren()).thenReturn(Collections.<Resource>emptySet().iterator());
+ lenient()
+ .when(emptyChild.listChildren())
+ .thenReturn(Collections.<Resource>emptySet().iterator());
Resource res = mock(Resource.class);
lenient().when(res.getChild("firstChild")).thenReturn(firstChild);
@@ -182,5 +195,4 @@
return factory.getAdapter(invocation.getMock(), ChildModel.class);
}
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/ResourcePathInjectionTest.java b/src/test/java/org/apache/sling/models/impl/ResourcePathInjectionTest.java
index 73d1d66..2fd93b1 100644
--- a/src/test/java/org/apache/sling/models/impl/ResourcePathInjectionTest.java
+++ b/src/test/java/org/apache/sling/models/impl/ResourcePathInjectionTest.java
@@ -18,14 +18,6 @@
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.lenient;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.doReturn;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -48,6 +40,14 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class ResourcePathInjectionTest {
private ModelAdapterFactory factory;
@@ -78,15 +78,15 @@
Map<String, Object> map = new HashMap<String, Object>();
map.put("propertyContainingAPath", "/some/other/path");
map.put("anotherPropertyContainingAPath", "/some/other/path2");
- String[] paths= new String[2];
- paths[0]="/some/other/path";
- paths[1]="/some/other/path2";
+ String[] paths = new String[2];
+ paths[0] = "/some/other/path";
+ paths[1] = "/some/other/path2";
- String[] invalidPaths= new String[3];
- invalidPaths[0]="/does/not/exist";
- invalidPaths[1]="/does/not/exist2";
- invalidPaths[2]="/some/other/path";
- map.put("propertyWithSeveralPaths",paths);
+ String[] invalidPaths = new String[3];
+ invalidPaths[0] = "/does/not/exist";
+ invalidPaths[1] = "/does/not/exist2";
+ invalidPaths[2] = "/some/other/path";
+ map.put("propertyWithSeveralPaths", paths);
map.put("propertyWithMissingPaths", invalidPaths);
ValueMap properties = new ValueMapDecorator(map);
@@ -106,9 +106,13 @@
factory.bindInjector(new SelfInjector(), new ServicePropertiesMap(1, Integer.MAX_VALUE));
factory.bindInjector(new ValueMapInjector(), new ServicePropertiesMap(2, 2000));
factory.bindInjector(new ResourcePathInjector(), new ServicePropertiesMap(3, 2500));
- factory.bindStaticInjectAnnotationProcessorFactory(new ResourcePathInjector(), new ServicePropertiesMap(3, 2500));
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(ResourcePathModel.class, ResourcePathPartialModel.class,
- ResourcePathAllOptionalModel.class, ResourcePathModelWrapping.class);
+ factory.bindStaticInjectAnnotationProcessorFactory(
+ new ResourcePathInjector(), new ServicePropertiesMap(3, 2500));
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ ResourcePathModel.class,
+ ResourcePathPartialModel.class,
+ ResourcePathAllOptionalModel.class,
+ ResourcePathModelWrapping.class);
}
@Test
@@ -149,24 +153,26 @@
public void testMultiplePathInjection() {
ResourcePathModel model = factory.getAdapter(adaptableResource, ResourcePathModel.class);
assertNotNull(model);
- List<Resource> resources=model.getMultipleResources();
+ List<Resource> resources = model.getMultipleResources();
assertNotNull(resources);
- assertEquals(2,resources.size());
+ assertEquals(2, resources.size());
assertEquals(byPropertyValueResource, resources.get(0));
assertEquals(byPropertyValueResource2, resources.get(1));
- List<Resource> resourcesFromPathAnnotation= model.getManyFromPath();
+ List<Resource> resourcesFromPathAnnotation = model.getManyFromPath();
assertNotNull(resourcesFromPathAnnotation);
assertEquals(byPathResource, resourcesFromPathAnnotation.get(0));
assertEquals(byPathResource2, resourcesFromPathAnnotation.get(1));
- List<Resource> resourcesFromResourcePathAnnotation= model.getManyFromPath2();
+ List<Resource> resourcesFromResourcePathAnnotation = model.getManyFromPath2();
assertNotNull(resourcesFromResourcePathAnnotation);
assertEquals(byPathResource2, resourcesFromResourcePathAnnotation.get(0));
assertEquals(byPathResource, resourcesFromResourcePathAnnotation.get(1));
assertNotNull(model.getPropertyWithSeveralPaths());
- assertEquals(byPropertyValueResource, model.getPropertyWithSeveralPaths().get(0));
- assertEquals(byPropertyValueResource2, model.getPropertyWithSeveralPaths().get(1));
+ assertEquals(
+ byPropertyValueResource, model.getPropertyWithSeveralPaths().get(0));
+ assertEquals(
+ byPropertyValueResource2, model.getPropertyWithSeveralPaths().get(1));
}
@Test
@@ -193,5 +199,4 @@
assertTrue(model.getFromPath().length > 0);
assertTrue(model.getMultipleResources().length > 0);
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/impl/SelfDependencyTest.java b/src/test/java/org/apache/sling/models/impl/SelfDependencyTest.java
index 1f0973f..58fc9d7 100644
--- a/src/test/java/org/apache/sling/models/impl/SelfDependencyTest.java
+++ b/src/test/java/org/apache/sling/models/impl/SelfDependencyTest.java
@@ -1,27 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.lenient;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.impl.injectors.SelfInjector;
import org.apache.sling.models.testmodels.classes.DirectCyclicSelfDependencyModel;
@@ -37,6 +33,12 @@
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.lenient;
+
@RunWith(MockitoJUnitRunner.class)
public class SelfDependencyTest {
@@ -58,7 +60,12 @@
factory = AdapterFactoryTest.createModelAdapterFactory();
factory.bindInjector(new SelfInjector(), new ServicePropertiesMap(1, 1));
- factory.adapterImplementations.addClassesAsAdapterAndImplementation(SelfDependencyModelA.class, SelfDependencyModelB.class, DirectCyclicSelfDependencyModel.class, IndirectCyclicSelfDependencyModelA.class, IndirectCyclicSelfDependencyModelB.class);
+ factory.adapterImplementations.addClassesAsAdapterAndImplementation(
+ SelfDependencyModelA.class,
+ SelfDependencyModelB.class,
+ DirectCyclicSelfDependencyModel.class,
+ IndirectCyclicSelfDependencyModelA.class,
+ IndirectCyclicSelfDependencyModelB.class);
}
@Test
@@ -78,9 +85,8 @@
@Test
public void testInddirectCyclicSelfDependency() {
- IndirectCyclicSelfDependencyModelA object = factory.getAdapter(request,
- IndirectCyclicSelfDependencyModelA.class);
+ IndirectCyclicSelfDependencyModelA object =
+ factory.getAdapter(request, IndirectCyclicSelfDependencyModelA.class);
assertNull(object);
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/ServicePropertiesMap.java b/src/test/java/org/apache/sling/models/impl/ServicePropertiesMap.java
index d424e5c..2cfa998 100644
--- a/src/test/java/org/apache/sling/models/impl/ServicePropertiesMap.java
+++ b/src/test/java/org/apache/sling/models/impl/ServicePropertiesMap.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
@@ -22,11 +24,10 @@
@SuppressWarnings("serial")
public class ServicePropertiesMap extends HashMap<String, Object> {
-
+
public ServicePropertiesMap(long serviceId, int serviceRanking) {
super();
put(Constants.SERVICE_ID, serviceId);
put(Constants.SERVICE_RANKING, serviceRanking);
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/StaticInjectionAPFLoadOrderTest.java b/src/test/java/org/apache/sling/models/impl/StaticInjectionAPFLoadOrderTest.java
index 24bcb63..71090ac 100644
--- a/src/test/java/org/apache/sling/models/impl/StaticInjectionAPFLoadOrderTest.java
+++ b/src/test/java/org/apache/sling/models/impl/StaticInjectionAPFLoadOrderTest.java
@@ -18,10 +18,6 @@
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.adapter.AdapterManager;
import org.apache.sling.api.resource.ResourceResolver;
@@ -39,17 +35,22 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
/**
* Test load order behavior of StaticInjectionAnnotationProcesssorFactory instances (SLING-5010).
*/
@RunWith(MockitoJUnitRunner.class)
public class StaticInjectionAPFLoadOrderTest {
-
+
@Rule
public OsgiContext context = new OsgiContext();
-
+
@Mock
private SlingHttpServletRequest request;
+
@Mock
private ResourceResolver resourceResolver;
@@ -58,14 +59,14 @@
@Mock
private AdapterManager adapterManager;
-
+
private ModelAdapterFactory factory;
-
+
@Before
public void setUp() {
registerServices();
}
-
+
/**
* Registration order: 1. ModelFactory, 2. custom injector, 3. model
*/
@@ -75,24 +76,24 @@
registerCustomInjector();
registerModel();
-
+
// this should not throw an exception because resourceResovler is marked as optional
assertFalse(createModel().hasResourceResolver());
}
-
+
/**
* Registration order: 1. ModelFactory, 2. custom injector, 3. model
*/
@Test
public void testFactory_Injector_Model_WithResourceResolver() {
when(request.getResourceResolver()).thenReturn(resourceResolver);
-
+
registerCustomInjector();
registerModel();
-
+
assertTrue(createModel().hasResourceResolver());
}
-
+
/**
* Registration order: 1. ModelFactory, 2. model, 3. custom injector
*/
@@ -102,24 +103,24 @@
registerModel();
registerCustomInjector();
-
+
// this should not throw an exception because resourceResovler is marked as optional
assertFalse(createModel().hasResourceResolver());
}
-
+
/**
* Registration order: 1. ModelFactory, 2. model, 3. custom injector
*/
@Test
public void testFactory_Model_Injector_WithResourceResolver() {
when(request.getResourceResolver()).thenReturn(resourceResolver);
-
+
registerModel();
registerCustomInjector();
-
+
assertTrue(createModel().hasResourceResolver());
}
-
+
private void registerServices() {
context.registerService(BindingsValuesProvidersByContext.class, bindingsValuesProvidersByContext);
context.registerService(AdapterManager.class, adapterManager);
@@ -137,18 +138,15 @@
private TestModel createModel() {
return factory.createModel(request, TestModel.class);
}
-
-
+
@Model(adaptables = SlingHttpServletRequest.class)
public static class TestModel {
-
+
@SlingObject(injectionStrategy = InjectionStrategy.OPTIONAL)
private ResourceResolver resourceResolver;
-
+
public boolean hasResourceResolver() {
return resourceResolver != null;
}
-
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/ViaTest.java b/src/test/java/org/apache/sling/models/impl/ViaTest.java
index e72a6b5..d02aee9 100644
--- a/src/test/java/org/apache/sling/models/impl/ViaTest.java
+++ b/src/test/java/org/apache/sling/models/impl/ViaTest.java
@@ -1,25 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.when;
-
import java.util.Collections;
import org.apache.commons.lang3.RandomStringUtils;
@@ -38,6 +36,10 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class ViaTest {
@@ -67,7 +69,7 @@
@Test
public void testProjectionToResource() {
String value = RandomStringUtils.randomAlphanumeric(10);
- ValueMap map = new ValueMapDecorator(Collections.<String, Object> singletonMap("firstProperty", value));
+ ValueMap map = new ValueMapDecorator(Collections.<String, Object>singletonMap("firstProperty", value));
when(resource.adaptTo(ValueMap.class)).thenReturn(map);
ViaModel model = factory.getAdapter(request, ViaModel.class);
@@ -78,11 +80,10 @@
@Test
public void testProjectionToChildResource() {
String value = RandomStringUtils.randomAlphanumeric(10);
- ValueMap map = new ValueMapDecorator(Collections.<String, Object> singletonMap("firstProperty", value));
+ ValueMap map = new ValueMapDecorator(Collections.<String, Object>singletonMap("firstProperty", value));
when(childResource.adaptTo(ValueMap.class)).thenReturn(map);
ChildResourceViaModel model = factory.getAdapter(resource, ChildResourceViaModel.class);
assertNotNull(model);
assertEquals(value, model.getFirstProperty());
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/implpicker/FirstImplementationPickerTest.java b/src/test/java/org/apache/sling/models/impl/implpicker/FirstImplementationPickerTest.java
index 1bc8cfb..6cdf3db 100644
--- a/src/test/java/org/apache/sling/models/impl/implpicker/FirstImplementationPickerTest.java
+++ b/src/test/java/org/apache/sling/models/impl/implpicker/FirstImplementationPickerTest.java
@@ -18,13 +18,13 @@
*/
package org.apache.sling.models.impl.implpicker;
-import static org.junit.Assert.assertEquals;
-
import org.apache.sling.models.impl.FirstImplementationPicker;
import org.apache.sling.models.spi.ImplementationPicker;
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
public class FirstImplementationPickerTest {
private static final Class<?> SAMPLE_ADAPTER = Comparable.class;
@@ -39,14 +39,13 @@
@Test
public void testPickOneImplementation() {
- Class<?>[] implementations = new Class<?>[] { String.class };
+ Class<?>[] implementations = new Class<?>[] {String.class};
assertEquals(String.class, underTest.pick(SAMPLE_ADAPTER, implementations, SAMPLE_ADAPTABLE));
}
@Test
public void testPickMultipleImplementations() {
- Class<?>[] implementations = new Class<?>[] { Integer.class, Long.class, String.class };
+ Class<?>[] implementations = new Class<?>[] {Integer.class, Long.class, String.class};
assertEquals(Integer.class, underTest.pick(SAMPLE_ADAPTER, implementations, SAMPLE_ADAPTABLE));
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/impl/injector/CustomAnnotation.java b/src/test/java/org/apache/sling/models/impl/injector/CustomAnnotation.java
index a2c9c55..e821a8f 100644
--- a/src/test/java/org/apache/sling/models/impl/injector/CustomAnnotation.java
+++ b/src/test/java/org/apache/sling/models/impl/injector/CustomAnnotation.java
@@ -1,32 +1,32 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.injector;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import org.apache.sling.models.spi.injectorspecific.InjectAnnotation;
-@Target({ METHOD, FIELD })
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+@Target({METHOD, FIELD})
@Retention(RUNTIME)
@InjectAnnotation
-public @interface CustomAnnotation {
-
-}
+public @interface CustomAnnotation {}
diff --git a/src/test/java/org/apache/sling/models/impl/injector/CustomAnnotationInjector.java b/src/test/java/org/apache/sling/models/impl/injector/CustomAnnotationInjector.java
index 84c61ae..8adf0ef 100644
--- a/src/test/java/org/apache/sling/models/impl/injector/CustomAnnotationInjector.java
+++ b/src/test/java/org/apache/sling/models/impl/injector/CustomAnnotationInjector.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.injector;
@@ -35,7 +37,11 @@
}
@Override
- public Object getValue(@NotNull Object adaptable, String name, @NotNull Type declaredType, @NotNull AnnotatedElement element,
+ public Object getValue(
+ @NotNull Object adaptable,
+ String name,
+ @NotNull Type declaredType,
+ @NotNull AnnotatedElement element,
@NotNull DisposalCallbackRegistry callbackRegistry) {
if (name.equals("customString")) {
return "custom value";
@@ -65,5 +71,4 @@
return "default value";
}
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/injector/SimpleInjector.java b/src/test/java/org/apache/sling/models/impl/injector/SimpleInjector.java
index 3b97ae9..6c4e19c 100644
--- a/src/test/java/org/apache/sling/models/impl/injector/SimpleInjector.java
+++ b/src/test/java/org/apache/sling/models/impl/injector/SimpleInjector.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.injector;
@@ -31,7 +33,11 @@
}
@Override
- public Object getValue(@NotNull Object adaptable, String name, @NotNull Type declaredType, @NotNull AnnotatedElement element,
+ public Object getValue(
+ @NotNull Object adaptable,
+ String name,
+ @NotNull Type declaredType,
+ @NotNull AnnotatedElement element,
@NotNull DisposalCallbackRegistry callbackRegistry) {
if (name.equals("testString") && declaredType.equals(String.class)) {
return "test string";
@@ -39,5 +45,4 @@
return null;
}
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/injectors/BindingsInjectorTest.java b/src/test/java/org/apache/sling/models/impl/injectors/BindingsInjectorTest.java
index b499079..f20d5a0 100644
--- a/src/test/java/org/apache/sling/models/impl/injectors/BindingsInjectorTest.java
+++ b/src/test/java/org/apache/sling/models/impl/injectors/BindingsInjectorTest.java
@@ -18,13 +18,10 @@
*/
package org.apache.sling.models.impl.injectors;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import javax.servlet.ServletRequest;
import java.lang.reflect.AnnotatedElement;
-import javax.servlet.ServletRequest;
-
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.scripting.SlingBindings;
import org.apache.sling.models.spi.DisposalCallbackRegistry;
@@ -34,6 +31,9 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
@RunWith(MockitoJUnitRunner.class)
public class BindingsInjectorTest {
@@ -41,10 +41,13 @@
@Mock
private ServletRequest request;
+
@Mock
private SlingBindings bindings;
+
@Mock
private AnnotatedElement element;
+
@Mock
private DisposalCallbackRegistry registry;
@@ -93,5 +96,4 @@
Object result = injector.getValue(request, STRING_PARAM, String.class, element, registry);
assertNull(result);
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/injectors/RequestAttributeInjectorTest.java b/src/test/java/org/apache/sling/models/impl/injectors/RequestAttributeInjectorTest.java
index a3ae8dc..1683e80 100644
--- a/src/test/java/org/apache/sling/models/impl/injectors/RequestAttributeInjectorTest.java
+++ b/src/test/java/org/apache/sling/models/impl/injectors/RequestAttributeInjectorTest.java
@@ -18,13 +18,10 @@
*/
package org.apache.sling.models.impl.injectors;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import javax.servlet.ServletRequest;
import java.lang.reflect.AnnotatedElement;
-import javax.servlet.ServletRequest;
-
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.models.spi.DisposalCallbackRegistry;
import org.junit.Before;
@@ -33,25 +30,30 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
@RunWith(MockitoJUnitRunner.class)
public class RequestAttributeInjectorTest {
private RequestAttributeInjector injector = new RequestAttributeInjector();
-
+
@Mock
private ServletRequest request;
+
@Mock
private AnnotatedElement element;
+
@Mock
private DisposalCallbackRegistry registry;
-
+
private static final String STRING_PARAM = "param1";
private static final String INTEGER_PARAM = "param2";
private static final String CLASS_PARAM = "param3";
private static final String STRING_VALUE = "myValue";
private static final int INTEGER_VALUE = 42;
private static final ResourceResolver CLASS_INSTANCE = mock(ResourceResolver.class);
-
+
@Before
public void setUp() {
when(request.getAttribute(STRING_PARAM)).thenReturn(STRING_VALUE);
diff --git a/src/test/java/org/apache/sling/models/impl/injectors/ResourceResolverInjectorTest.java b/src/test/java/org/apache/sling/models/impl/injectors/ResourceResolverInjectorTest.java
index f8776ce..142c1a0 100644
--- a/src/test/java/org/apache/sling/models/impl/injectors/ResourceResolverInjectorTest.java
+++ b/src/test/java/org/apache/sling/models/impl/injectors/ResourceResolverInjectorTest.java
@@ -18,9 +18,6 @@
*/
package org.apache.sling.models.impl.injectors;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
import java.lang.reflect.AnnotatedElement;
import org.apache.sling.api.SlingHttpServletRequest;
@@ -33,6 +30,9 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
/**
* This was a unit test for the ResourceResolverInjector which is now removed
* because it is obsolete due to the SlingObjectInjector.
@@ -43,9 +43,10 @@
public class ResourceResolverInjectorTest {
private SlingObjectInjector injector = new SlingObjectInjector();
-
+
@Mock
private AnnotatedElement element;
+
@Mock
private DisposalCallbackRegistry registry;
@@ -76,5 +77,4 @@
Object result = injector.getValue(response, "resourceResolver", ResourceResolver.class, element, registry);
assertNull(result);
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/injectors/SelfInjectorTest.java b/src/test/java/org/apache/sling/models/impl/injectors/SelfInjectorTest.java
index 02a790d..023a63c 100644
--- a/src/test/java/org/apache/sling/models/impl/injectors/SelfInjectorTest.java
+++ b/src/test/java/org/apache/sling/models/impl/injectors/SelfInjectorTest.java
@@ -18,16 +18,11 @@
*/
package org.apache.sling.models.impl.injectors;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.lenient;
-import static org.mockito.Mockito.when;
+import javax.servlet.http.HttpServletRequest;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
-import javax.servlet.http.HttpServletRequest;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
@@ -42,6 +37,11 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class SelfInjectorTest {
@@ -65,45 +65,104 @@
@Before
public void setup() {
lenient().when(modelAnnotation.defaultInjectionStrategy()).thenReturn(DefaultInjectionStrategy.REQUIRED);
- firstConstructorParameter = new ConstructorParameter(new Annotation[0], Object.class, Object.class, true, 0,
- new StaticInjectAnnotationProcessorFactory[0], null);
- secondConstructorParameter = new ConstructorParameter(new Annotation[0], Object.class, Object.class, true, 1,
- new StaticInjectAnnotationProcessorFactory[0], null);
+ firstConstructorParameter = new ConstructorParameter(
+ new Annotation[0],
+ Object.class,
+ Object.class,
+ true,
+ 0,
+ new StaticInjectAnnotationProcessorFactory[0],
+ null);
+ secondConstructorParameter = new ConstructorParameter(
+ new Annotation[0],
+ Object.class,
+ Object.class,
+ true,
+ 1,
+ new StaticInjectAnnotationProcessorFactory[0],
+ null);
}
@Test
public void testMatchingClass() {
- assertSame(request, injector.getValue(request, "notRelevant", SlingHttpServletRequest.class, firstConstructorParameter.getAnnotatedElement(), registry));
- assertNull(injector.getValue(request, "notRelevant", SlingHttpServletRequest.class, secondConstructorParameter.getAnnotatedElement(), registry));
- assertNull(injector.getValue(request, "notRelevant", SlingHttpServletRequest.class, annotatedElement, registry));
+ assertSame(
+ request,
+ injector.getValue(
+ request,
+ "notRelevant",
+ SlingHttpServletRequest.class,
+ firstConstructorParameter.getAnnotatedElement(),
+ registry));
+ assertNull(injector.getValue(
+ request,
+ "notRelevant",
+ SlingHttpServletRequest.class,
+ secondConstructorParameter.getAnnotatedElement(),
+ registry));
+ assertNull(
+ injector.getValue(request, "notRelevant", SlingHttpServletRequest.class, annotatedElement, registry));
}
@Test
public void testMatchingSubClass() {
- assertSame(request, injector.getValue(request, "notRelevant", HttpServletRequest.class, firstConstructorParameter.getAnnotatedElement(), registry));
- assertNull(injector.getValue(request, "notRelevant", HttpServletRequest.class, secondConstructorParameter.getAnnotatedElement(), registry));
+ assertSame(
+ request,
+ injector.getValue(
+ request,
+ "notRelevant",
+ HttpServletRequest.class,
+ firstConstructorParameter.getAnnotatedElement(),
+ registry));
+ assertNull(injector.getValue(
+ request,
+ "notRelevant",
+ HttpServletRequest.class,
+ secondConstructorParameter.getAnnotatedElement(),
+ registry));
assertNull(injector.getValue(request, "notRelevant", HttpServletRequest.class, annotatedElement, registry));
}
@Test
public void testNotMatchingClass() {
- assertNull(injector.getValue(request, "notRelevant", ResourceResolver.class, firstConstructorParameter.getAnnotatedElement(), registry));
- assertNull(injector.getValue(request, "notRelevant", ResourceResolver.class, secondConstructorParameter.getAnnotatedElement(), registry));
+ assertNull(injector.getValue(
+ request,
+ "notRelevant",
+ ResourceResolver.class,
+ firstConstructorParameter.getAnnotatedElement(),
+ registry));
+ assertNull(injector.getValue(
+ request,
+ "notRelevant",
+ ResourceResolver.class,
+ secondConstructorParameter.getAnnotatedElement(),
+ registry));
assertNull(injector.getValue(request, "notRelevant", ResourceResolver.class, annotatedElement, registry));
}
@Test
public void testWithNullName() {
- assertSame(request, injector.getValue(request, null, SlingHttpServletRequest.class, firstConstructorParameter.getAnnotatedElement(), registry));
- assertNull(injector.getValue(request, null, SlingHttpServletRequest.class, secondConstructorParameter.getAnnotatedElement(), registry));
+ assertSame(
+ request,
+ injector.getValue(
+ request,
+ null,
+ SlingHttpServletRequest.class,
+ firstConstructorParameter.getAnnotatedElement(),
+ registry));
+ assertNull(injector.getValue(
+ request,
+ null,
+ SlingHttpServletRequest.class,
+ secondConstructorParameter.getAnnotatedElement(),
+ registry));
assertNull(injector.getValue(request, null, SlingHttpServletRequest.class, annotatedElement, registry));
}
@Test
public void testMatchingClassWithSelfAnnotation() {
when(annotatedElement.isAnnotationPresent(Self.class)).thenReturn(true);
- Object result = injector
- .getValue(request, "notRelevant", SlingHttpServletRequest.class, annotatedElement, registry);
+ Object result =
+ injector.getValue(request, "notRelevant", SlingHttpServletRequest.class, annotatedElement, registry);
assertSame(request, result);
}
@@ -113,5 +172,4 @@
Object result = injector.getValue(request, "notRelevant", ResourceResolver.class, annotatedElement, registry);
assertSame(request, result);
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorRequestTest.java b/src/test/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorRequestTest.java
index 93aab11..589f5c3 100644
--- a/src/test/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorRequestTest.java
+++ b/src/test/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorRequestTest.java
@@ -18,14 +18,11 @@
*/
package org.apache.sling.models.impl.injectors;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
-import java.lang.reflect.AnnotatedElement;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.lang.reflect.AnnotatedElement;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
@@ -40,6 +37,9 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
@RunWith(MockitoJUnitRunner.class)
public class SlingObjectInjectorRequestTest {
@@ -47,16 +47,22 @@
@Mock
private AnnotatedElement annotatedElement;
+
@Mock
private SlingHttpServletRequest request;
+
@Mock
private SlingHttpServletResponse response;
+
@Mock
private SlingScriptHelper scriptHelper;
+
@Mock
private ResourceResolver resourceResolver;
+
@Mock
private Resource resource;
+
@Mock
private DisposalCallbackRegistry registry;
@@ -72,7 +78,8 @@
@Test
public void testResourceResolver() {
- Object result = this.injector.getValue(this.request, null, ResourceResolver.class, this.annotatedElement, registry);
+ Object result =
+ this.injector.getValue(this.request, null, ResourceResolver.class, this.annotatedElement, registry);
assertSame(this.resourceResolver, result);
}
@@ -88,8 +95,8 @@
@Test
public void testRequest() {
- Object result = this.injector.getValue(this.request, null, SlingHttpServletRequest.class,
- this.annotatedElement, registry);
+ Object result = this.injector.getValue(
+ this.request, null, SlingHttpServletRequest.class, this.annotatedElement, registry);
assertSame(this.request, result);
result = this.injector.getValue(this.request, null, HttpServletRequest.class, this.annotatedElement, registry);
@@ -98,8 +105,8 @@
@Test
public void testResponse() {
- Object result = this.injector.getValue(this.request, null, SlingHttpServletResponse.class,
- this.annotatedElement, registry);
+ Object result = this.injector.getValue(
+ this.request, null, SlingHttpServletResponse.class, this.annotatedElement, registry);
assertSame(this.response, result);
result = this.injector.getValue(this.request, null, HttpServletResponse.class, this.annotatedElement, registry);
@@ -108,8 +115,8 @@
@Test
public void testScriptHelper() {
- Object result = this.injector
- .getValue(this.request, null, SlingScriptHelper.class, this.annotatedElement, registry);
+ Object result =
+ this.injector.getValue(this.request, null, SlingScriptHelper.class, this.annotatedElement, registry);
assertSame(this.scriptHelper, result);
}
@@ -118,5 +125,4 @@
Object result = this.injector.getValue(this, null, SlingScriptHelper.class, this.annotatedElement, registry);
assertNull(result);
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorResourceResolverTest.java b/src/test/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorResourceResolverTest.java
index d2379a8..4176150 100644
--- a/src/test/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorResourceResolverTest.java
+++ b/src/test/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorResourceResolverTest.java
@@ -18,9 +18,6 @@
*/
package org.apache.sling.models.impl.injectors;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-
import java.lang.reflect.AnnotatedElement;
import org.apache.sling.api.SlingHttpServletResponse;
@@ -33,6 +30,9 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+
@RunWith(MockitoJUnitRunner.class)
public class SlingObjectInjectorResourceResolverTest {
@@ -40,43 +40,45 @@
@Mock
private AnnotatedElement annotatedElement;
+
@Mock
private ResourceResolver resourceResolver;
+
@Mock
private DisposalCallbackRegistry registry;
@Test
public void testResourceResolver() {
- Object result = this.injector.getValue(this.resourceResolver, null, ResourceResolver.class,
- this.annotatedElement, registry);
+ Object result = this.injector.getValue(
+ this.resourceResolver, null, ResourceResolver.class, this.annotatedElement, registry);
assertSame(this.resourceResolver, result);
}
@Test
public void testResource() {
- Object result = this.injector
- .getValue(this.resourceResolver, null, Resource.class, this.annotatedElement, registry);
+ Object result =
+ this.injector.getValue(this.resourceResolver, null, Resource.class, this.annotatedElement, registry);
assertNull(result);
}
@Test
public void testRequest() {
- Object result = this.injector.getValue(this.resourceResolver, null, SlingHttpServletResponse.class,
- this.annotatedElement, registry);
+ Object result = this.injector.getValue(
+ this.resourceResolver, null, SlingHttpServletResponse.class, this.annotatedElement, registry);
assertNull(result);
}
@Test
public void testResponse() {
- Object result = this.injector.getValue(this.resourceResolver, null, SlingHttpServletResponse.class,
- this.annotatedElement, registry);
+ Object result = this.injector.getValue(
+ this.resourceResolver, null, SlingHttpServletResponse.class, this.annotatedElement, registry);
assertNull(result);
}
@Test
public void testScriptHelper() {
- Object result = this.injector.getValue(this.resourceResolver, null, SlingScriptHelper.class,
- this.annotatedElement, registry);
+ Object result = this.injector.getValue(
+ this.resourceResolver, null, SlingScriptHelper.class, this.annotatedElement, registry);
assertNull(result);
}
@@ -85,5 +87,4 @@
Object result = this.injector.getValue(this, null, SlingScriptHelper.class, this.annotatedElement, registry);
assertNull(result);
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorResourceTest.java b/src/test/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorResourceTest.java
index 62ac700..a4af146 100644
--- a/src/test/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorResourceTest.java
+++ b/src/test/java/org/apache/sling/models/impl/injectors/SlingObjectInjectorResourceTest.java
@@ -18,10 +18,6 @@
*/
package org.apache.sling.models.impl.injectors;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.when;
-
import java.lang.reflect.AnnotatedElement;
import org.apache.sling.api.SlingHttpServletResponse;
@@ -36,6 +32,10 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class SlingObjectInjectorResourceTest {
@@ -60,8 +60,8 @@
@Test
public void testResourceResolver() {
- Object result = this.injector
- .getValue(this.resource, null, ResourceResolver.class, this.annotatedElement, registry);
+ Object result =
+ this.injector.getValue(this.resource, null, ResourceResolver.class, this.annotatedElement, registry);
assertSame(this.resourceResolver, result);
}
@@ -77,22 +77,22 @@
@Test
public void testRequest() {
- Object result = this.injector.getValue(this.resource, null, SlingHttpServletResponse.class,
- this.annotatedElement, registry);
+ Object result = this.injector.getValue(
+ this.resource, null, SlingHttpServletResponse.class, this.annotatedElement, registry);
assertNull(result);
}
@Test
public void testResponse() {
- Object result = this.injector.getValue(this.resource, null, SlingHttpServletResponse.class,
- this.annotatedElement, registry);
+ Object result = this.injector.getValue(
+ this.resource, null, SlingHttpServletResponse.class, this.annotatedElement, registry);
assertNull(result);
}
@Test
public void testScriptHelper() {
- Object result = this.injector.getValue(this.resource, null, SlingScriptHelper.class, this.annotatedElement,
- registry);
+ Object result =
+ this.injector.getValue(this.resource, null, SlingScriptHelper.class, this.annotatedElement, registry);
assertNull(result);
}
@@ -101,5 +101,4 @@
Object result = this.injector.getValue(this, null, SlingScriptHelper.class, this.annotatedElement, registry);
assertNull(result);
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/injectors/ValueMapInjectorTest.java b/src/test/java/org/apache/sling/models/impl/injectors/ValueMapInjectorTest.java
index 4b46789..8f58a21 100644
--- a/src/test/java/org/apache/sling/models/impl/injectors/ValueMapInjectorTest.java
+++ b/src/test/java/org/apache/sling/models/impl/injectors/ValueMapInjectorTest.java
@@ -18,9 +18,6 @@
*/
package org.apache.sling.models.impl.injectors;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
import java.lang.reflect.AnnotatedElement;
import org.apache.sling.api.resource.Resource;
@@ -33,6 +30,9 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
@RunWith(MockitoJUnitRunner.class)
public class ValueMapInjectorTest {
@@ -40,8 +40,10 @@
@Mock
private ValueMap valueMap;
+
@Mock
private AnnotatedElement element;
+
@Mock
private DisposalCallbackRegistry registry;
@@ -88,5 +90,4 @@
Object result = injector.getValue(mock(ResourceResolver.class), STRING_PARAM, String.class, element, registry);
assertNull(result);
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/via/ChildResourceViaProviderTest.java b/src/test/java/org/apache/sling/models/impl/via/ChildResourceViaProviderTest.java
index 0271c0b..3939a8e 100644
--- a/src/test/java/org/apache/sling/models/impl/via/ChildResourceViaProviderTest.java
+++ b/src/test/java/org/apache/sling/models/impl/via/ChildResourceViaProviderTest.java
@@ -1,23 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.via;
-import static org.mockito.Mockito.when;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.junit.Assert;
@@ -27,6 +27,8 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class ChildResourceViaProviderTest {
@@ -59,5 +61,4 @@
Resource adaptableResource = ((SlingHttpServletRequest) adaptable).getResource();
Assert.assertEquals(adaptableResource, childResource);
}
-
}
diff --git a/src/test/java/org/apache/sling/models/impl/via/OriginalResourceTypeViaProviderTest.java b/src/test/java/org/apache/sling/models/impl/via/OriginalResourceTypeViaProviderTest.java
index a793b0c..fd0beda 100644
--- a/src/test/java/org/apache/sling/models/impl/via/OriginalResourceTypeViaProviderTest.java
+++ b/src/test/java/org/apache/sling/models/impl/via/OriginalResourceTypeViaProviderTest.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.impl.via;
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ArrayOSGiModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ArrayOSGiModel.java
index 3e31a97..7e26c30 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ArrayOSGiModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ArrayOSGiModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -24,12 +26,11 @@
@Model(adaptables = Resource.class)
public class ArrayOSGiModel {
-
+
@Inject
private ServiceInterface[] services;
-
+
public ServiceInterface[] getServices() {
return services;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ArrayPrimitivesModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ArrayPrimitivesModel.java
index d89384f..e611cc0 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ArrayPrimitivesModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ArrayPrimitivesModel.java
@@ -1,26 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
+import javax.inject.Inject;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
-import javax.inject.Inject;
-
@Model(adaptables = Resource.class)
public class ArrayPrimitivesModel {
@@ -37,4 +39,4 @@
public int[] getSecondIntArray() {
return secondIntArray;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ArrayWrappersModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ArrayWrappersModel.java
index e691e06..fc5ced5 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ArrayWrappersModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ArrayWrappersModel.java
@@ -1,26 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
+import javax.inject.Inject;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
-import javax.inject.Inject;
-
@Model(adaptables = Resource.class)
public class ArrayWrappersModel {
@@ -37,4 +39,4 @@
public Integer[] getSecondIntArray() {
return secondIntArray;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/BindingsModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/BindingsModel.java
index 81f1a65..03767ff 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/BindingsModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/BindingsModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -24,16 +26,16 @@
import org.apache.sling.models.annotations.Model;
import org.slf4j.Logger;
-@Model(adaptables=SlingHttpServletRequest.class)
+@Model(adaptables = SlingHttpServletRequest.class)
public class BindingsModel {
-
+
@Inject
@Named("sling")
private SlingScriptHelper sling;
@Inject
private Logger log;
-
+
public SlingScriptHelper getSling() {
return sling;
}
@@ -41,5 +43,4 @@
public Logger getLog() {
return log;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/CachedModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/CachedModel.java
index 2a10933..466dcb9 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/CachedModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/CachedModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -22,7 +24,9 @@
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
-@Model(adaptables = {SlingHttpServletRequest.class, Resource.class}, cache = true)
+@Model(
+ adaptables = {SlingHttpServletRequest.class, Resource.class},
+ cache = true)
public class CachedModel {
@Inject
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/CachedModelWithAdapterTypes12.java b/src/test/java/org/apache/sling/models/testmodels/classes/CachedModelWithAdapterTypes12.java
index fbcef3f..9226ab2 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/CachedModelWithAdapterTypes12.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/CachedModelWithAdapterTypes12.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -22,11 +24,7 @@
import org.apache.sling.models.testmodels.interfaces.AdapterType2;
@Model(
- adaptables = SlingHttpServletRequest.class,
- adapters = { AdapterType1.class, AdapterType2.class },
- cache = true
-)
-public class CachedModelWithAdapterTypes12 implements AdapterType1, AdapterType2 {
-
-
-}
+ adaptables = SlingHttpServletRequest.class,
+ adapters = {AdapterType1.class, AdapterType2.class},
+ cache = true)
+public class CachedModelWithAdapterTypes12 implements AdapterType1, AdapterType2 {}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/CachedModelWithAdapterTypes23.java b/src/test/java/org/apache/sling/models/testmodels/classes/CachedModelWithAdapterTypes23.java
index 365c73a..e4409ba 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/CachedModelWithAdapterTypes23.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/CachedModelWithAdapterTypes23.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -22,11 +24,7 @@
import org.apache.sling.models.testmodels.interfaces.AdapterType3;
@Model(
- adaptables = SlingHttpServletRequest.class,
- adapters = { AdapterType2.class, AdapterType3.class },
- cache = true
-)
-public class CachedModelWithAdapterTypes23 implements AdapterType2, AdapterType3 {
-
-
-}
+ adaptables = SlingHttpServletRequest.class,
+ adapters = {AdapterType2.class, AdapterType3.class},
+ cache = true)
+public class CachedModelWithAdapterTypes23 implements AdapterType2, AdapterType3 {}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/CachedModelWithSelfReference.java b/src/test/java/org/apache/sling/models/testmodels/classes/CachedModelWithSelfReference.java
index 2ca8755..9e370f3 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/CachedModelWithSelfReference.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/CachedModelWithSelfReference.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -31,4 +33,4 @@
// Add a big array of longs to the class, to make it take fewer iterations to fill the heap
public long[] longs = new long[numberOfLongs];
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ChildModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ChildModel.java
index 071e37f..35b62ea 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ChildModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ChildModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -26,7 +28,7 @@
@Inject
private String property;
-
+
public String getProperty() {
return property;
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceModel.java
index c69242f..018891e 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceModel.java
@@ -1,26 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
-import java.util.List;
-
import javax.inject.Inject;
import javax.inject.Named;
+import java.util.List;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
@@ -30,10 +32,12 @@
@Inject
private Resource firstChild;
- @Inject @Named("secondChild")
+ @Inject
+ @Named("secondChild")
private List<Resource> grandChildren;
- @Inject @Named("emptyChild")
+ @Inject
+ @Named("emptyChild")
private List<Resource> emptyGrandChildren;
public Resource getFirstChild() {
@@ -47,5 +51,4 @@
public List<Resource> getEmptyGrandChildren() {
return emptyGrandChildren;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceViaModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceViaModel.java
index 345e9aa..a1a10fa 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceViaModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceViaModel.java
@@ -1,28 +1,30 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
+import javax.inject.Inject;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Via;
import org.apache.sling.models.annotations.via.ChildResource;
-import javax.inject.Inject;
-
@Model(adaptables = Resource.class)
public class ChildResourceViaModel {
@@ -33,5 +35,4 @@
public String getFirstProperty() {
return firstProperty;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ChildValueMapModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ChildValueMapModel.java
index 01d1aea..1c96355 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ChildValueMapModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ChildValueMapModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -27,9 +29,8 @@
@Inject
private ValueMap firstChild;
-
+
public ValueMap getFirstChild() {
return firstChild;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/CollectionDefaultsModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/CollectionDefaultsModel.java
index 666f1c1..6dd1991 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/CollectionDefaultsModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/CollectionDefaultsModel.java
@@ -1,25 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
-import java.util.Collection;
-
import javax.inject.Inject;
+import java.util.Collection;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Model;
@@ -28,11 +30,11 @@
public class CollectionDefaultsModel {
@Inject
- @Default(intValues = {1,2,3})
+ @Default(intValues = {1, 2, 3})
private Collection<Integer> intList;
@Inject
- @Default(values = {"v1","v2"})
+ @Default(values = {"v1", "v2"})
private Collection<String> stringList;
public Collection<Integer> getIntCollection() {
@@ -42,5 +44,4 @@
public Collection<String> getStringCollection() {
return stringList;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/CollectionOSGiModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/CollectionOSGiModel.java
index 115b5e4..2ac2a2e 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/CollectionOSGiModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/CollectionOSGiModel.java
@@ -1,37 +1,38 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
-import java.util.Collection;
-
import javax.inject.Inject;
+import java.util.Collection;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.testmodels.interfaces.ServiceInterface;
@Model(adaptables = Resource.class)
public class CollectionOSGiModel {
-
+
@Inject
private Collection<ServiceInterface> services;
-
+
public Collection<ServiceInterface> getServices() {
return services;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ConstructorWithExceptionModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ConstructorWithExceptionModel.java
index 72be3cc..2555740 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ConstructorWithExceptionModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ConstructorWithExceptionModel.java
@@ -1,25 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
-@Model(adaptables=Resource.class)
+@Model(adaptables = Resource.class)
public class ConstructorWithExceptionModel {
public ConstructorWithExceptionModel() {
throw new RuntimeException("Exception thrown in constructor");
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/DefaultPrimitivesModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/DefaultPrimitivesModel.java
index d9b41cd..08660a6 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/DefaultPrimitivesModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/DefaultPrimitivesModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -30,7 +32,7 @@
private boolean booleanProperty;
@Inject
- @Default(booleanValues = { true, true })
+ @Default(booleanValues = {true, true})
private boolean[] booleanArrayProperty;
@Inject
@@ -38,8 +40,9 @@
private long longProperty;
@Inject
- @Default(longValues = { 1L, 1L })
+ @Default(longValues = {1L, 1L})
private long[] longArrayProperty;
+
public boolean getBooleanProperty() {
return booleanProperty;
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/DefaultStringModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/DefaultStringModel.java
index fecfcb0..fda79dd 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/DefaultStringModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/DefaultStringModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -30,7 +32,7 @@
private String firstProperty;
@Inject
- @Default(values = { "firstDefault", "secondDefault" })
+ @Default(values = {"firstDefault", "secondDefault"})
private String[] secondProperty;
public String getFirstProperty() {
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/DefaultWrappersModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/DefaultWrappersModel.java
index a64c23c..11a849e 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/DefaultWrappersModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/DefaultWrappersModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -30,7 +32,7 @@
private Boolean booleanWrapperProperty;
@Inject
- @Default(booleanValues = { true, true })
+ @Default(booleanValues = {true, true})
private Boolean[] booleanWrapperArrayProperty;
@Inject
@@ -38,7 +40,7 @@
private Long longWrapperProperty;
@Inject
- @Default(longValues = { 1L, 1L })
+ @Default(longValues = {1L, 1L})
private Long[] longWrapperArrayProperty;
public Boolean getBooleanWrapperProperty() {
@@ -56,5 +58,4 @@
public Long[] getLongWrapperArrayProperty() {
return longWrapperArrayProperty;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/DirectCyclicSelfDependencyModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/DirectCyclicSelfDependencyModel.java
index 297acbe..17c1a7f 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/DirectCyclicSelfDependencyModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/DirectCyclicSelfDependencyModel.java
@@ -22,7 +22,7 @@
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.Self;
-@Model(adaptables=SlingHttpServletRequest.class)
+@Model(adaptables = SlingHttpServletRequest.class)
public class DirectCyclicSelfDependencyModel {
@Self
@@ -31,5 +31,4 @@
public DirectCyclicSelfDependencyModel getModelSelf() {
return modelSelf;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/FailingPostConstructModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/FailingPostConstructModel.java
index 186306f..adeb07a 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/FailingPostConstructModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/FailingPostConstructModel.java
@@ -23,12 +23,11 @@
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
-@Model(adaptables=Resource.class)
+@Model(adaptables = Resource.class)
public class FailingPostConstructModel {
@PostConstruct
protected void pc() throws Exception {
throw new Exception("FAIL");
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/FalsePostConstructModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/FalsePostConstructModel.java
index a1bd687..3186483 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/FalsePostConstructModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/FalsePostConstructModel.java
@@ -18,17 +18,16 @@
*/
package org.apache.sling.models.testmodels.classes;
+import javax.annotation.PostConstruct;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
-import javax.annotation.PostConstruct;
-
-@Model(adaptables=Resource.class)
+@Model(adaptables = Resource.class)
public class FalsePostConstructModel {
@PostConstruct
protected boolean pc() throws Exception {
return false;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelA.java b/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelA.java
index 375d867..12959e3 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelA.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelA.java
@@ -22,7 +22,7 @@
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.Self;
-@Model(adaptables=SlingHttpServletRequest.class)
+@Model(adaptables = SlingHttpServletRequest.class)
public class IndirectCyclicSelfDependencyModelA {
@Self
@@ -31,5 +31,4 @@
public IndirectCyclicSelfDependencyModelB getDependencyB() {
return dependencyB;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelB.java b/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelB.java
index 7207c8c..c551796 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelB.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelB.java
@@ -22,7 +22,7 @@
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.Self;
-@Model(adaptables=SlingHttpServletRequest.class)
+@Model(adaptables = SlingHttpServletRequest.class)
public class IndirectCyclicSelfDependencyModelB {
@Self
@@ -31,5 +31,4 @@
public IndirectCyclicSelfDependencyModelA getDependencyA() {
return dependencyA;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/InjectorSpecificAnnotationModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/InjectorSpecificAnnotationModel.java
index ecbd32d..bbfe057 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/InjectorSpecificAnnotationModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/InjectorSpecificAnnotationModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -78,5 +80,4 @@
public Resource getChildResource() {
return childResource;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/InvalidConstructorModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/InvalidConstructorModel.java
index bf032b6..1149d49 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/InvalidConstructorModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/InvalidConstructorModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/InvalidModelWithMissingAnnotation.java b/src/test/java/org/apache/sling/models/testmodels/classes/InvalidModelWithMissingAnnotation.java
index 41e4de9..3da6bde 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/InvalidModelWithMissingAnnotation.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/InvalidModelWithMissingAnnotation.java
@@ -1,30 +1,31 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
import javax.inject.Inject;
public class InvalidModelWithMissingAnnotation {
-
+
@Inject
private String attribute;
-
- public InvalidModelWithMissingAnnotation() {
- }
+
+ public InvalidModelWithMissingAnnotation() {}
public String getAttribute() {
return attribute;
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ListDefaultsModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ListDefaultsModel.java
index f4b66e8..6712f1e 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ListDefaultsModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ListDefaultsModel.java
@@ -1,25 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
-import java.util.List;
-
import javax.inject.Inject;
+import java.util.List;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Model;
@@ -28,19 +30,19 @@
public class ListDefaultsModel {
@Inject
- @Default(values = {"v1","v2"})
+ @Default(values = {"v1", "v2"})
private List<String> stringList;
@Inject
- @Default(intValues = {1,2,3})
+ @Default(intValues = {1, 2, 3})
private List<Integer> intList;
@Inject
- @Default(longValues = {1,2})
+ @Default(longValues = {1, 2})
private List<Long> longList;
@Inject
- @Default(booleanValues = {true,false})
+ @Default(booleanValues = {true, false})
private List<Boolean> booleanList;
@Inject
@@ -48,11 +50,11 @@
private List<Short> shortList;
@Inject
- @Default(floatValues = {1.1f,1.2f})
+ @Default(floatValues = {1.1f, 1.2f})
private List<Float> floatList;
@Inject
- @Default(doubleValues = {1.1d,1.2d,1.3d})
+ @Default(doubleValues = {1.1d, 1.2d, 1.3d})
private List<Double> doubleList;
public List<String> getStringList() {
@@ -82,5 +84,4 @@
public List<Double> getDoubleList() {
return doubleList;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ListModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ListModel.java
index 564f923..4901d98 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ListModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ListModel.java
@@ -1,25 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
-import java.util.List;
-
import javax.inject.Inject;
+import java.util.List;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Optional;
@@ -48,5 +50,4 @@
public List<String> getEmptyStringList() {
return emptyStringList;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ListOSGiModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ListOSGiModel.java
index 33b2ed4..b133e55 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ListOSGiModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ListOSGiModel.java
@@ -1,37 +1,38 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
-import java.util.List;
-
import javax.inject.Inject;
+import java.util.List;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.testmodels.interfaces.ServiceInterface;
@Model(adaptables = Resource.class)
public class ListOSGiModel {
-
+
@Inject
private List<ServiceInterface> services;
-
+
public List<ServiceInterface> getServices() {
return services;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/OptionalArrayOSGiModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/OptionalArrayOSGiModel.java
index 84aac68..213dbcc 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/OptionalArrayOSGiModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/OptionalArrayOSGiModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -25,12 +27,12 @@
@Model(adaptables = Resource.class)
public class OptionalArrayOSGiModel {
-
- @Inject @Optional
+
+ @Inject
+ @Optional
private ServiceInterface[] services;
-
+
public ServiceInterface[] getServices() {
return services;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/OptionalListOSGiModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/OptionalListOSGiModel.java
index b8a2146..20c3c35 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/OptionalListOSGiModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/OptionalListOSGiModel.java
@@ -1,25 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
-import java.util.List;
-
import javax.inject.Inject;
+import java.util.List;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Optional;
@@ -27,12 +29,12 @@
@Model(adaptables = Resource.class)
public class OptionalListOSGiModel {
-
- @Inject @Optional
+
+ @Inject
+ @Optional
private List<ServiceInterface> services;
-
+
public List<ServiceInterface> getServices() {
return services;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/OptionalObjectsModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/OptionalObjectsModel.java
index 5d20865..46d7661 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/OptionalObjectsModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/OptionalObjectsModel.java
@@ -1,25 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
+import javax.inject.Inject;
+
import java.util.Collection;
import java.util.List;
import java.util.Optional;
-import javax.inject.Inject;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/OptionalPrimitivesModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/OptionalPrimitivesModel.java
index 2f9aad2..dd55265 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/OptionalPrimitivesModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/OptionalPrimitivesModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -25,52 +27,68 @@
@Model(adaptables = Resource.class)
public class OptionalPrimitivesModel {
- @Inject @Optional
+ @Inject
+ @Optional
private byte byteValue;
- @Inject @Optional
+ @Inject
+ @Optional
private short shortValue;
- @Inject @Optional
+ @Inject
+ @Optional
private int intValue;
- @Inject @Optional
+ @Inject
+ @Optional
private long longValue;
- @Inject @Optional
+ @Inject
+ @Optional
private float floatValue;
- @Inject @Optional
+ @Inject
+ @Optional
private double doubleValue;
- @Inject @Optional
+ @Inject
+ @Optional
private char charValue;
- @Inject @Optional
+ @Inject
+ @Optional
private boolean booleanValue;
- @Inject @Optional
+ @Inject
+ @Optional
private Byte byteObjectValue;
- @Inject @Optional
+ @Inject
+ @Optional
private Short shortObjectValue;
- @Inject @Optional
+ @Inject
+ @Optional
private Integer intObjectValue;
- @Inject @Optional
+ @Inject
+ @Optional
private Long longObjectValue;
- @Inject @Optional
+ @Inject
+ @Optional
private Float floatObjectValue;
- @Inject @Optional
+ @Inject
+ @Optional
private Double doubleObjectValue;
- @Inject @Optional
+ @Inject
+ @Optional
private Character charObjectValue;
- @Inject @Optional
+ @Inject
+ @Optional
private Boolean booleanObjectValue;
public byte getByteValue() {
@@ -136,5 +154,4 @@
public Boolean getBooleanObjectValue() {
return this.booleanObjectValue;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ParentModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ParentModel.java
index c714e32..271dd04 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ParentModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ParentModel.java
@@ -1,26 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
-import java.util.List;
-
import javax.inject.Inject;
import javax.inject.Named;
+import java.util.List;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
@@ -30,10 +32,12 @@
@Inject
private ChildModel firstChild;
- @Inject @Named("secondChild")
+ @Inject
+ @Named("secondChild")
private List<ChildModel> grandChildren;
- @Inject @Named("emptyChild")
+ @Inject
+ @Named("emptyChild")
private List<ChildModel> emptyGrandChildren;
public ChildModel getFirstChild() {
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/RequestOSGiModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/RequestOSGiModel.java
index 253e9ef..a83cf12 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/RequestOSGiModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/RequestOSGiModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -24,12 +26,11 @@
@Model(adaptables = SlingHttpServletRequest.class)
public class RequestOSGiModel {
-
+
@Inject
private ServiceInterface service;
-
+
public ServiceInterface getService() {
return service;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ResourceModelWithRequiredField.java b/src/test/java/org/apache/sling/models/testmodels/classes/ResourceModelWithRequiredField.java
index adf6856..ea6d57d 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ResourceModelWithRequiredField.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ResourceModelWithRequiredField.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -30,5 +32,4 @@
public String getRequired() {
return required;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ResourceModelWithRequiredFieldOptionalStrategy.java b/src/test/java/org/apache/sling/models/testmodels/classes/ResourceModelWithRequiredFieldOptionalStrategy.java
index 57d1786..e0954ff 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ResourceModelWithRequiredFieldOptionalStrategy.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ResourceModelWithRequiredFieldOptionalStrategy.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -28,11 +30,12 @@
@Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class ResourceModelWithRequiredFieldOptionalStrategy {
- // although this is marked with optional=false, this is still optional, because injectionStrategy has a higher priority (even if it is only the default)
+ // although this is marked with optional=false, this is still optional, because injectionStrategy has a higher
+ // priority (even if it is only the default)
// compare also with https://issues.apache.org/jira/browse/SLING-4155
- @ValueMapValue(optional=false)
+ @ValueMapValue(optional = false)
private String optional5;
-
+
@SuppressWarnings("unused")
@Inject
private String optional1;
@@ -40,17 +43,17 @@
@Inject
@Required
private String required1;
-
+
@ValueMapValue
private String optional2;
-
- @ValueMapValue(optional=true)
+
+ @ValueMapValue(optional = true)
private String optional3;
-
- @ValueMapValue(injectionStrategy=InjectionStrategy.OPTIONAL)
+
+ @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
private String optional4;
-
- @ValueMapValue(injectionStrategy=InjectionStrategy.REQUIRED)
+
+ @ValueMapValue(injectionStrategy = InjectionStrategy.REQUIRED)
private String required2;
public String getRequired1() {
@@ -60,6 +63,4 @@
public String getRequired2() {
return required2;
}
-
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathAllOptionalModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathAllOptionalModel.java
index 38fc7f9..6750fb8 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathAllOptionalModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathAllOptionalModel.java
@@ -40,16 +40,16 @@
@Named("propertyContainingAPath")
@Optional
private Resource derefProperty;
-
+
@Inject
- @Path(paths={"/some/invalidpath", "/some/invalidpath2"})
+ @Path(paths = {"/some/invalidpath", "/some/invalidpath2"})
@Optional
private Resource manyFromPathNonList;
- @ResourcePath(path = "/some/invalidpath2", optional=true)
+ @ResourcePath(path = "/some/invalidpath2", optional = true)
private Resource fromPath2;
- @ResourcePath(name = "anotherPropertyContainingAPath", optional=true)
+ @ResourcePath(name = "anotherPropertyContainingAPath", optional = true)
private Resource derefProperty2;
public Resource getFromPath() {
@@ -67,5 +67,4 @@
public Resource getByDerefProperty2() {
return derefProperty2;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathModel.java
index e1dd2c8..020be9d 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathModel.java
@@ -18,11 +18,11 @@
*/
package org.apache.sling.models.testmodels.classes;
-import java.util.List;
-
import javax.inject.Inject;
import javax.inject.Named;
+import java.util.List;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
@@ -39,20 +39,20 @@
@Inject
@Named("propertyContainingAPath")
private Resource derefProperty;
-
+
@Inject
- @Path(paths={"/some/path", "/some/path2"})
+ @Path(paths = {"/some/path", "/some/path2"})
private List<Resource> manyFromPath;
-
- @ResourcePath(paths={"/some/path2","/some/path"})
+
+ @ResourcePath(paths = {"/some/path2", "/some/path"})
private List<Resource> manyFromPath2;
@ResourcePath(path = "/some/path2")
private Resource fromPath2;
-
- @ResourcePath(name="propertyWithSeveralPaths")
+
+ @ResourcePath(name = "propertyWithSeveralPaths")
private List<Resource> multipleResources;
-
+
@ResourcePath
private List<Resource> propertyWithSeveralPaths;
@@ -74,20 +74,20 @@
public Resource getByDerefProperty2() {
return derefProperty2;
}
-
- public List<Resource> getMultipleResources(){
- return this.multipleResources;
+
+ public List<Resource> getMultipleResources() {
+ return this.multipleResources;
}
-
- public List<Resource> getManyFromPath(){
+
+ public List<Resource> getManyFromPath() {
return this.manyFromPath;
}
-
- public List<Resource> getManyFromPath2(){
+
+ public List<Resource> getManyFromPath2() {
return this.manyFromPath2;
}
- public List<Resource> getPropertyWithSeveralPaths(){
+ public List<Resource> getPropertyWithSeveralPaths() {
return this.propertyWithSeveralPaths;
}
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathModelWrapping.java b/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathModelWrapping.java
index 15f225b..6cd2018 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathModelWrapping.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathModelWrapping.java
@@ -23,7 +23,7 @@
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.ResourcePath;
-@Model(adaptables = { Resource.class, SlingHttpServletRequest.class })
+@Model(adaptables = {Resource.class, SlingHttpServletRequest.class})
public class ResourcePathModelWrapping {
@ResourcePath(path = "/some/path")
@@ -39,5 +39,4 @@
public Resource[] getMultipleResources() {
return this.multipleResources;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathPartialModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathPartialModel.java
index c69d4c1..01a4987 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathPartialModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ResourcePathPartialModel.java
@@ -30,23 +30,22 @@
@Model(adaptables = {Resource.class, SlingHttpServletRequest.class})
public class ResourcePathPartialModel {
-
- @ResourcePath(name="propertyWithSeveralPaths", injectionStrategy=InjectionStrategy.REQUIRED)
+
+ @ResourcePath(name = "propertyWithSeveralPaths", injectionStrategy = InjectionStrategy.REQUIRED)
private List<Resource> requiredResources;
-
- @ResourcePath(name="propertyWithSeveralPaths")
+
+ @ResourcePath(name = "propertyWithSeveralPaths")
@Required
private List<Resource> requiredResources2;
-
-
- @ResourcePath(name="propertyWithMissingPaths", injectionStrategy=InjectionStrategy.OPTIONAL)
+
+ @ResourcePath(name = "propertyWithMissingPaths", injectionStrategy = InjectionStrategy.OPTIONAL)
private List<Resource> optionalResources;
-
+
@Optional
- @ResourcePath(name="propertyWithMissingPaths")
+ @ResourcePath(name = "propertyWithMissingPaths")
private List<Resource> optionalResources2;
-
- @ResourcePath(name="propertyWithMissingPaths", optional=true)
+
+ @ResourcePath(name = "propertyWithMissingPaths", optional = true)
private List<Resource> optionalResources3;
public List<Resource> getRequiredResources() {
@@ -68,5 +67,4 @@
public List<Resource> getOptionalResources3() {
return optionalResources3;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelA.java b/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelA.java
index 1f318d0..7e10d58 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelA.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelA.java
@@ -22,7 +22,7 @@
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.Self;
-@Model(adaptables=SlingHttpServletRequest.class)
+@Model(adaptables = SlingHttpServletRequest.class)
public class SelfDependencyModelA {
@Self
@@ -31,5 +31,4 @@
public SelfDependencyModelB getDependencyB() {
return dependencyB;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelB.java b/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelB.java
index 91a6087..8713369 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelB.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelB.java
@@ -22,7 +22,7 @@
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.Self;
-@Model(adaptables=SlingHttpServletRequest.class)
+@Model(adaptables = SlingHttpServletRequest.class)
public class SelfDependencyModelB {
@Self
@@ -31,5 +31,4 @@
public SlingHttpServletRequest getRequest() {
return request;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/SetOSGiModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/SetOSGiModel.java
index 9e185c6..873d6b9 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/SetOSGiModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/SetOSGiModel.java
@@ -1,37 +1,38 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
-import java.util.Set;
-
import javax.inject.Inject;
+import java.util.Set;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.testmodels.interfaces.ServiceInterface;
@Model(adaptables = Resource.class)
public class SetOSGiModel {
-
+
@Inject
private Set<ServiceInterface> services;
-
+
public Set<ServiceInterface> getServices() {
return services;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/SimpleModelWithInvalidSecondAnnotation.java b/src/test/java/org/apache/sling/models/testmodels/classes/SimpleModelWithInvalidSecondAnnotation.java
index 03f7be1..95a2c87 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/SimpleModelWithInvalidSecondAnnotation.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/SimpleModelWithInvalidSecondAnnotation.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -22,6 +24,4 @@
@Model(adaptables = Resource.class)
@OtherAnnotation()
-public class SimpleModelWithInvalidSecondAnnotation {
-
-}
+public class SimpleModelWithInvalidSecondAnnotation {}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/SimpleOSGiModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/SimpleOSGiModel.java
index 1fc3d62..addef07 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/SimpleOSGiModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/SimpleOSGiModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -24,12 +26,11 @@
@Model(adaptables = Resource.class)
public class SimpleOSGiModel {
-
+
@Inject
private ServiceInterface service;
-
+
public ServiceInterface getService() {
return service;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/SimplePropertyModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/SimplePropertyModel.java
index 1c9c05f..8d38f6c 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/SimplePropertyModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/SimplePropertyModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -74,5 +76,4 @@
public boolean isPostConstructCalled() {
return postConstructCalled;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/SubClass.java b/src/test/java/org/apache/sling/models/testmodels/classes/SubClass.java
index ff5c7a4..722778c 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/SubClass.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/SubClass.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -21,7 +23,7 @@
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
-@Model(adaptables=Resource.class)
+@Model(adaptables = Resource.class)
public class SubClass extends SuperClass {
private long postConstructCalledTimestampInSub;
@@ -29,7 +31,7 @@
public long getPostConstructCalledTimestampInSub() {
return postConstructCalledTimestampInSub;
}
-
+
@PostConstruct
protected void pc2() {
try {
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/SubClassOverriddenPostConstruct.java b/src/test/java/org/apache/sling/models/testmodels/classes/SubClassOverriddenPostConstruct.java
index 41f61d9..c756b2e 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/SubClassOverriddenPostConstruct.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/SubClassOverriddenPostConstruct.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -21,14 +23,14 @@
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
-@Model(adaptables=Resource.class)
+@Model(adaptables = Resource.class)
public class SubClassOverriddenPostConstruct extends SuperClass {
int postConstructorCalledCounter = 0;
-
+
public int getPostConstructorCalledCounter() {
return postConstructorCalledCounter;
}
-
+
@PostConstruct
protected void pc() {
postConstructorCalledCounter++;
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/SuperClass.java b/src/test/java/org/apache/sling/models/testmodels/classes/SuperClass.java
index a7047ce..89c6412 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/SuperClass.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/SuperClass.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -30,5 +32,4 @@
protected void pc() {
postConstructCalledTimestampInSuper = System.currentTimeMillis();
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/SuperclassConstructorModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/SuperclassConstructorModel.java
index c764fc7..b296f9b 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/SuperclassConstructorModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/SuperclassConstructorModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -34,8 +36,7 @@
this.request = request;
}
- public SuperclassConstructorModel() {
- }
+ public SuperclassConstructorModel() {}
public int getAttribute() {
return attribute;
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/TruePostConstructModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/TruePostConstructModel.java
index 06d21db..4881db9 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/TruePostConstructModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/TruePostConstructModel.java
@@ -18,17 +18,16 @@
*/
package org.apache.sling.models.testmodels.classes;
+import javax.annotation.PostConstruct;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
-import javax.annotation.PostConstruct;
-
-@Model(adaptables=Resource.class)
+@Model(adaptables = Resource.class)
public class TruePostConstructModel {
@PostConstruct
protected boolean pc() throws Exception {
return true;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/UncachedModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/UncachedModel.java
index 06ae166..b2032a1 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/UncachedModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/UncachedModel.java
@@ -1,22 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
-
import javax.inject.Inject;
import org.apache.sling.api.SlingHttpServletRequest;
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/ViaModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ViaModel.java
index 5e5054e..ab760c1 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/ViaModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ViaModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -32,5 +34,4 @@
public String getFirstProperty() {
return firstProperty;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/WithOneConstructorModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/WithOneConstructorModel.java
index c16b980..40aeae5 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/WithOneConstructorModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/WithOneConstructorModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/WithThreeConstructorsModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/WithThreeConstructorsModel.java
index d701341..038580e 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/WithThreeConstructorsModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/WithThreeConstructorsModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -26,7 +28,7 @@
public class WithThreeConstructorsModel {
private SlingHttpServletRequest request;
-
+
private SlingHttpServletResponse response;
@Inject
@@ -41,8 +43,7 @@
this.request = request;
}
- public WithThreeConstructorsModel() {
- }
+ public WithThreeConstructorsModel() {}
public int getAttribute() {
return attribute;
@@ -51,7 +52,7 @@
public SlingHttpServletRequest getRequest() {
return request;
}
-
+
public SlingHttpServletResponse getResponse() {
return response;
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/WithTwoConstructorsModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/WithTwoConstructorsModel.java
index edadf24..9b3650b 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/WithTwoConstructorsModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/WithTwoConstructorsModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes;
@@ -33,8 +35,7 @@
this.request = request;
}
- public WithTwoConstructorsModel() {
- }
+ public WithTwoConstructorsModel() {}
public int getAttribute() {
return attribute;
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/annotations/Hidden.java b/src/test/java/org/apache/sling/models/testmodels/classes/annotations/Hidden.java
index 0b09f8a..918641e 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/annotations/Hidden.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/annotations/Hidden.java
@@ -1,21 +1,21 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.annotations;
-public class Hidden {
-
-}
+public class Hidden {}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/annotations/OtherAnnotation.java b/src/test/java/org/apache/sling/models/testmodels/classes/annotations/OtherAnnotation.java
index 52e7c6e..bf79ca3 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/annotations/OtherAnnotation.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/annotations/OtherAnnotation.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.annotations;
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/BindingsModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/BindingsModel.java
index 518f892..b438253 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/BindingsModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/BindingsModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.constructorinjection;
@@ -29,7 +31,6 @@
private final SlingScriptHelper sling;
-
@Inject
private Logger log;
@@ -45,4 +46,4 @@
public Logger getLog() {
return log;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultPrimitivesModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultPrimitivesModel.java
index c07c346..f01052b 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultPrimitivesModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultPrimitivesModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.constructorinjection;
@@ -32,11 +34,10 @@
@Inject
public DefaultPrimitivesModel(
- @Default(booleanValues = true) boolean booleanProperty,
- @Default(booleanValues = { true, true }) boolean[] booleanArrayProperty,
+ @Default(booleanValues = true) boolean booleanProperty,
+ @Default(booleanValues = {true, true}) boolean[] booleanArrayProperty,
@Default(longValues = 1L) long longProperty,
- @Default(longValues = { 1L, 1L }) long[] longArrayProperty
- ) {
+ @Default(longValues = {1L, 1L}) long[] longArrayProperty) {
this.booleanProperty = booleanProperty;
this.booleanArrayProperty = booleanArrayProperty;
this.longProperty = longProperty;
@@ -58,4 +59,4 @@
public long[] getLongArrayProperty() {
return longArrayProperty;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultStringModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultStringModel.java
index eae00a3..cb6621b 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultStringModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultStringModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.constructorinjection;
@@ -31,8 +33,7 @@
@Inject
public DefaultStringModel(
@Default(values = "firstDefault") String firstProperty,
- @Default(values = { "firstDefault", "secondDefault" }) String[] secondProperty
- ) {
+ @Default(values = {"firstDefault", "secondDefault"}) String[] secondProperty) {
this.firstProperty = firstProperty;
this.secondProperty = secondProperty;
}
@@ -44,4 +45,4 @@
public String[] getSecondProperty() {
return secondProperty;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultWrappersModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultWrappersModel.java
index 1e8f640..3a6e225 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultWrappersModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultWrappersModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.constructorinjection;
@@ -33,10 +35,9 @@
@Inject
public DefaultWrappersModel(
@Default(booleanValues = true) Boolean booleanWrapperProperty,
- @Default(booleanValues = { true, true }) Boolean[] booleanWrapperArrayProperty,
+ @Default(booleanValues = {true, true}) Boolean[] booleanWrapperArrayProperty,
@Default(longValues = 1L) Long longWrapperProperty,
- @Default(longValues = { 1L, 1L }) Long[] longWrapperArrayProperty
- ) {
+ @Default(longValues = {1L, 1L}) Long[] longWrapperArrayProperty) {
this.booleanWrapperProperty = booleanWrapperProperty;
this.booleanWrapperArrayProperty = booleanWrapperArrayProperty;
this.longWrapperProperty = longWrapperProperty;
@@ -58,5 +59,4 @@
public Long[] getLongWrapperArrayProperty() {
return longWrapperArrayProperty;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/InjectorSpecificAnnotationModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/InjectorSpecificAnnotationModel.java
index db86dc7..0871d52 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/InjectorSpecificAnnotationModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/InjectorSpecificAnnotationModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.constructorinjection;
@@ -48,8 +50,7 @@
@ScriptVariable(optional = true, name = "sling") SlingScriptHelper helper,
@RequestAttribute(optional = true, name = "attribute") Object requestAttribute,
@OSGiService(optional = true) Logger service,
- @ChildResource(optional = true, name = "child1") Resource childResource
- ) {
+ @ChildResource(optional = true, name = "child1") Resource childResource) {
this.first = first;
this.secondWithOtherName = secondWithOtherName;
this.log = log;
@@ -86,5 +87,4 @@
public Resource getChildResource() {
return childResource;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ListOSGiModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ListOSGiModel.java
index db83733..4c60d33 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ListOSGiModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ListOSGiModel.java
@@ -1,25 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.constructorinjection;
-import java.util.List;
-
import javax.inject.Inject;
+import java.util.List;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.testmodels.interfaces.ServiceInterface;
@@ -37,5 +39,4 @@
public List<ServiceInterface> getServices() {
return services;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/NoNameModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/NoNameModel.java
index 4909ebe..341b215 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/NoNameModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/NoNameModel.java
@@ -37,5 +37,4 @@
public SlingScriptHelper getSling() {
return sling;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/OptionalPrimitivesModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/OptionalPrimitivesModel.java
index e465fc4..3b3ae46 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/OptionalPrimitivesModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/OptionalPrimitivesModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.constructorinjection;
@@ -109,7 +111,7 @@
public boolean getBooleanValue() {
return this.booleanValue;
}
-
+
public Byte getByteObjectValue() {
return this.byteObjectValue;
}
@@ -141,5 +143,4 @@
public Boolean getBooleanObjectValue() {
return this.booleanObjectValue;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ParentModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ParentModel.java
index 7c30148..2fdff6b 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ParentModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ParentModel.java
@@ -18,11 +18,11 @@
*/
package org.apache.sling.models.testmodels.classes.constructorinjection;
-import java.util.List;
-
import javax.inject.Inject;
import javax.inject.Named;
+import java.util.List;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.testmodels.classes.ChildModel;
@@ -31,7 +31,9 @@
public class ParentModel {
@Inject
- public ParentModel(@Named("firstChild") ChildModel firstChild, @Named("secondChild") List<ChildModel> grandChildren,
+ public ParentModel(
+ @Named("firstChild") ChildModel firstChild,
+ @Named("secondChild") List<ChildModel> grandChildren,
@Named("emptyChild") List<ChildModel> emptyGrandChildren) {
this.firstChild = firstChild;
this.grandChildren = grandChildren;
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/SimpleOSGiModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/SimpleOSGiModel.java
index 6695ab7..d4cd6b1 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/SimpleOSGiModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/SimpleOSGiModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.constructorinjection;
@@ -35,5 +37,4 @@
public ServiceInterface getService() {
return service;
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ViaRequestSuffixModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ViaRequestSuffixModel.java
index affd62f..dfb1eb8 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ViaRequestSuffixModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ViaRequestSuffixModel.java
@@ -1,27 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.constructorinjection;
+import javax.inject.Inject;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Via;
-import javax.inject.Inject;
-
@Model(adaptables = SlingHttpServletRequest.class)
public class ViaRequestSuffixModel {
@@ -35,4 +37,4 @@
public String getSuffix() {
return suffix;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/WithThreeConstructorsOneInjectModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/WithThreeConstructorsOneInjectModel.java
index 197e22b..e4e556b 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/WithThreeConstructorsOneInjectModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/WithThreeConstructorsOneInjectModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.constructorinjection;
@@ -36,8 +38,7 @@
this.request = request;
}
- public WithThreeConstructorsOneInjectModel() {
- }
+ public WithThreeConstructorsOneInjectModel() {}
@Inject
public WithThreeConstructorsOneInjectModel(@Named("attribute2") String attribute2) {
@@ -55,4 +56,4 @@
public SlingHttpServletRequest getRequest() {
return request;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorvisibility/PackagePrivateConstructorModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorvisibility/PackagePrivateConstructorModel.java
index cb3cdba..19b6906 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorvisibility/PackagePrivateConstructorModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorvisibility/PackagePrivateConstructorModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.constructorvisibility;
@@ -25,7 +27,5 @@
public class PackagePrivateConstructorModel {
@Inject
- PackagePrivateConstructorModel() {
- }
-
+ PackagePrivateConstructorModel() {}
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorvisibility/PrivateConstructorModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorvisibility/PrivateConstructorModel.java
index 85eef0d..8cf0763 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorvisibility/PrivateConstructorModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorvisibility/PrivateConstructorModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.constructorvisibility;
@@ -25,7 +27,5 @@
public class PrivateConstructorModel {
@Inject
- private PrivateConstructorModel() {
- }
-
+ private PrivateConstructorModel() {}
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/constructorvisibility/ProtectedConstructorModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/constructorvisibility/ProtectedConstructorModel.java
index aa3f2de..65f0212 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/constructorvisibility/ProtectedConstructorModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/constructorvisibility/ProtectedConstructorModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.constructorvisibility;
@@ -25,7 +27,5 @@
public class ProtectedConstructorModel {
@Inject
- protected ProtectedConstructorModel() {
- }
-
+ protected ProtectedConstructorModel() {}
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/EvenSimplerPropertyModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/EvenSimplerPropertyModel.java
index 3d9173f..effc91c 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/EvenSimplerPropertyModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/EvenSimplerPropertyModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.implextend;
@@ -26,5 +28,4 @@
public String getFirst() {
return first;
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/ExtendsClassPropertyModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/ExtendsClassPropertyModel.java
index 6ab6d26..4023bc5 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/ExtendsClassPropertyModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/ExtendsClassPropertyModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.implextend;
@@ -20,15 +22,16 @@
import org.apache.sling.models.annotations.Model;
/**
- * This is an example for a model that can not be adapted itself, but only
+ * This is an example for a model that can not be adapted itself, but only
* to a superclass it extends. This superclass is defined as "adapters".
*/
-@Model(adaptables = Resource.class, adapters = { SimplePropertyModel.class, EvenSimplerPropertyModel.class })
+@Model(
+ adaptables = Resource.class,
+ adapters = {SimplePropertyModel.class, EvenSimplerPropertyModel.class})
public class ExtendsClassPropertyModel extends SimplePropertyModel {
@Override
public String getAllProperties() {
return "!" + super.getAllProperties() + "!";
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/ImplementsInterfacePropertyModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/ImplementsInterfacePropertyModel.java
index a4d5d5f..e83526c 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/ImplementsInterfacePropertyModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/ImplementsInterfacePropertyModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.implextend;
@@ -24,10 +26,12 @@
import org.apache.sling.models.annotations.Optional;
/**
- * This is an example for a model that can not be adapted itself, but only
+ * This is an example for a model that can not be adapted itself, but only
* to an interface it implements. This interfaces is defined as "adapters".
*/
-@Model(adaptables = Resource.class, adapters = { SampleServiceInterface.class, ImplementsInterfacePropertyModel.class })
+@Model(
+ adaptables = Resource.class,
+ adapters = {SampleServiceInterface.class, ImplementsInterfacePropertyModel.class})
public class ImplementsInterfacePropertyModel implements SampleServiceInterface {
@Inject
@@ -44,12 +48,7 @@
@Override
public String getAllProperties() {
StringBuilder sb = new StringBuilder();
- sb.append(first)
- .append("|")
- .append(second)
- .append("|")
- .append(thirdProperty);
+ sb.append(first).append("|").append(second).append("|").append(thirdProperty);
return sb.toString();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/ImplementsInterfacePropertyModel2.java b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/ImplementsInterfacePropertyModel2.java
index a4df61c..cb3f0a1 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/ImplementsInterfacePropertyModel2.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/ImplementsInterfacePropertyModel2.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.implextend;
@@ -43,12 +45,7 @@
@Override
public String getAllProperties() {
StringBuilder sb = new StringBuilder();
- sb.append(first)
- .append("|")
- .append(second)
- .append("|")
- .append(thirdProperty);
+ sb.append(first).append("|").append(second).append("|").append(thirdProperty);
return sb.toString();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/InvalidImplementsInterfacePropertyModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/InvalidImplementsInterfacePropertyModel.java
index 980b9b4..f7c60f7 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/InvalidImplementsInterfacePropertyModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/InvalidImplementsInterfacePropertyModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.implextend;
@@ -43,12 +45,7 @@
@Override
public String getAllProperties() {
StringBuilder sb = new StringBuilder();
- sb.append(first)
- .append("|")
- .append(second)
- .append("|")
- .append(thirdProperty);
+ sb.append(first).append("|").append(second).append("|").append(thirdProperty);
return sb.toString();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/InvalidSampleServiceInterface.java b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/InvalidSampleServiceInterface.java
index 38ab451..14cd2de 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/InvalidSampleServiceInterface.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/InvalidSampleServiceInterface.java
@@ -27,5 +27,4 @@
* @return concanated string with all properties
*/
String getAllProperties();
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/SampleServiceInterface.java b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/SampleServiceInterface.java
index 753c802..d0229e0 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/SampleServiceInterface.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/SampleServiceInterface.java
@@ -27,5 +27,4 @@
* @return concatenated string with all properties
*/
String getAllProperties();
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/SimplePropertyModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/SimplePropertyModel.java
index 7ab8c5f..37f2088 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/implextend/SimplePropertyModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/implextend/SimplePropertyModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.classes.implextend;
@@ -36,12 +38,7 @@
public String getAllProperties() {
StringBuilder sb = new StringBuilder();
- sb.append(getFirst())
- .append("|")
- .append(second)
- .append("|")
- .append(thirdProperty);
+ sb.append(getFirst()).append("|").append(second).append("|").append(thirdProperty);
return sb.toString();
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/AdapterType1.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/AdapterType1.java
index 74ba097..fc64285 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/AdapterType1.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/AdapterType1.java
@@ -1,20 +1,21 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
-public interface AdapterType1 {
-}
+public interface AdapterType1 {}
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/AdapterType2.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/AdapterType2.java
index ccd9d75..8ac229b 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/AdapterType2.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/AdapterType2.java
@@ -1,20 +1,21 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
-public interface AdapterType2 {
-}
+public interface AdapterType2 {}
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/AdapterType3.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/AdapterType3.java
index c629012..ef623ba 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/AdapterType3.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/AdapterType3.java
@@ -1,20 +1,21 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
-public interface AdapterType3 {
-}
+public interface AdapterType3 {}
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/CachedModel.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/CachedModel.java
index 491593d..980d7ce 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/CachedModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/CachedModel.java
@@ -1,26 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
+import javax.inject.Inject;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.Model;
-import javax.inject.Inject;
-
@Model(adaptables = SlingHttpServletRequest.class, cache = true)
public interface CachedModel {
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildModel.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildModel.java
index d74d550..2cbe162 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildResourceModel.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildResourceModel.java
index b2ce65c..b5c2c45 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildResourceModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildResourceModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
@@ -26,5 +28,4 @@
@Inject
public Resource getFirstChild();
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildValueMapModel.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildValueMapModel.java
index e7021d7..f98bc26 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildValueMapModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildValueMapModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
@@ -27,5 +29,4 @@
@Inject
public ValueMap getFirstChild();
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/ModelWithDefaultMethods.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/ModelWithDefaultMethods.java
index 6c254e8..4118860 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/ModelWithDefaultMethods.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/ModelWithDefaultMethods.java
@@ -1,33 +1,35 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
+import javax.inject.Inject;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Optional;
-import javax.inject.Inject;
-
@Model(adaptables = Resource.class)
public interface ModelWithDefaultMethods {
- @Inject @Optional
- default public String getProp() {
+ @Inject
+ @Optional
+ public default String getProp() {
return "default";
}
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/OptionalPrimitivesModel.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/OptionalPrimitivesModel.java
index 1a07c18..c0004b8 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/OptionalPrimitivesModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/OptionalPrimitivesModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
@@ -25,52 +27,67 @@
@Model(adaptables = Resource.class)
public interface OptionalPrimitivesModel {
- @Inject @Optional
+ @Inject
+ @Optional
public byte getByteValue();
- @Inject @Optional
+ @Inject
+ @Optional
public short getShortValue();
- @Inject @Optional
+ @Inject
+ @Optional
public int getIntValue();
- @Inject @Optional
+ @Inject
+ @Optional
public long getLongValue();
- @Inject @Optional
+ @Inject
+ @Optional
public float getFloatValue();
- @Inject @Optional
+ @Inject
+ @Optional
public double getDoubleValue();
- @Inject @Optional
+ @Inject
+ @Optional
public char getCharValue();
- @Inject @Optional
+ @Inject
+ @Optional
public boolean getBooleanValue();
- @Inject @Optional
+ @Inject
+ @Optional
public Byte getByteObjectValue();
- @Inject @Optional
+ @Inject
+ @Optional
public Short getShortObjectValue();
- @Inject @Optional
+ @Inject
+ @Optional
public Integer getIntObjectValue();
- @Inject @Optional
+ @Inject
+ @Optional
public Long getLongObjectValue();
- @Inject @Optional
+ @Inject
+ @Optional
public Float getFloatObjectValue();
- @Inject @Optional
+ @Inject
+ @Optional
public Double getDoubleObjectValue();
- @Inject @Optional
+ @Inject
+ @Optional
public Character getCharObjectValue();
- @Inject @Optional
+ @Inject
+ @Optional
public Boolean getBooleanObjectValue();
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
index 90c6c65..0c684fc 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
@@ -1,26 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
-import java.util.List;
-
import javax.inject.Inject;
import javax.inject.Named;
+import java.util.List;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
@@ -29,10 +31,12 @@
@Inject
public ChildModel getFirstChild();
-
- @Inject @Named("secondChild")
+
+ @Inject
+ @Named("secondChild")
public List<ChildModel> getGrandChildren();
- @Inject @Named("emptyChild")
+ @Inject
+ @Named("emptyChild")
public List<ChildModel> getEmptyGrandChildren();
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/PropertyModelWithDefaults.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/PropertyModelWithDefaults.java
index ec34e62..2a15fcc 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/PropertyModelWithDefaults.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/PropertyModelWithDefaults.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
@@ -26,10 +28,13 @@
@Model(adaptables = Resource.class)
public interface PropertyModelWithDefaults {
- @Inject @Optional @Default(values = "first default")
+ @Inject
+ @Optional
+ @Default(values = "first default")
public String getFirst();
- @Inject @Optional @Default(values = "second default")
+ @Inject
+ @Optional
+ @Default(values = "second default")
public String getSecond();
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/ResourceModelWithRequiredField.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/ResourceModelWithRequiredField.java
index dd68f78..f72bd20 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/ResourceModelWithRequiredField.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/ResourceModelWithRequiredField.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
@@ -26,5 +28,4 @@
@Inject
public String getRequired();
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/ServiceInterface.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/ServiceInterface.java
index 73c9b41..33f7e6b 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/ServiceInterface.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/ServiceInterface.java
@@ -1,21 +1,21 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
-public interface ServiceInterface {
-
-}
+public interface ServiceInterface {}
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/SimplePropertyModel.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/SimplePropertyModel.java
index cdff785..a244c09 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/SimplePropertyModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/SimplePropertyModel.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
@@ -36,8 +38,7 @@
@Inject
@Named("third")
public String getThirdProperty();
-
+
@Inject
public boolean isFourth();
-
}
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/SubClassModel.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/SubClassModel.java
index 947e3f7..1ff8647 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/SubClassModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/SubClassModel.java
@@ -1,26 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
+import javax.inject.Inject;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
-import javax.inject.Inject;
-
@Model(adaptables = Resource.class)
public interface SubClassModel extends SuperClassModel {
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/SuperClassModel.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/SuperClassModel.java
index ee749a1..0943dd9 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/SuperClassModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/SuperClassModel.java
@@ -1,26 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
+import javax.inject.Inject;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
-import javax.inject.Inject;
-
@Model(adaptables = Resource.class)
public interface SuperClassModel {
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/UncachedModel.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/UncachedModel.java
index 79614e8..de4bd6d 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/UncachedModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/UncachedModel.java
@@ -1,26 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.models.testmodels.interfaces;
+import javax.inject.Inject;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.Model;
-import javax.inject.Inject;
-
@Model(adaptables = SlingHttpServletRequest.class)
public interface UncachedModel {
diff --git a/src/test/java/org/apache/sling/models/testutil/ModelAdapterFactoryUtil.java b/src/test/java/org/apache/sling/models/testutil/ModelAdapterFactoryUtil.java
index 898a998..e90dfb5 100644
--- a/src/test/java/org/apache/sling/models/testutil/ModelAdapterFactoryUtil.java
+++ b/src/test/java/org/apache/sling/models/testutil/ModelAdapterFactoryUtil.java
@@ -77,7 +77,7 @@
}
@Override
- public Dictionary<String,String> getHeaders() {
+ public Dictionary<String, String> getHeaders() {
Dictionary<String, String> headers = new Hashtable<>();
headers.put("Sling-Model-Packages", "dummy.package");
return headers;
@@ -89,8 +89,7 @@
for (int i = 0; i < classes.length; i++) {
try {
urls.add(new URL("file:/" + classes[i].getName().replace('.', '/') + ".class"));
- }
- catch (MalformedURLException ex) {
+ } catch (MalformedURLException ex) {
throw new RuntimeException("Malformed URL.", ex);
}
}
@@ -173,7 +172,7 @@
}
@Override
- public Dictionary<String,String> getHeaders(String locale) {
+ public Dictionary<String, String> getHeaders(String locale) {
return null;
}
@@ -227,5 +226,4 @@
throw new UnsupportedOperationException();
}
}
-
}