Skip to content
This repository was archived by the owner on Nov 18, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/**
* The MIT License
*
* Copyright (c) 2017, Mahmoud Ben Hassine ([email protected])
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Copyright (c) 2017, Mahmoud Ben Hassine ([email protected])
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.jeasy.props.processors;

Expand All @@ -41,8 +41,8 @@
*/
public abstract class AbstractAnnotationProcessor<A extends Annotation> implements AnnotationProcessor<A> {

public static final String FILE_RESOURCE_PREFIX = "file:";
public static final String CLASSPATH_RESOURCE_PREFIX = "classpath:";
private static final String FILE_RESOURCE_PREFIX = "file:";
private static final String CLASSPATH_RESOURCE_PREFIX = "classpath:";

/**
* Constructs an error message to signal missing annotation attribute value.
Expand Down Expand Up @@ -77,14 +77,14 @@ protected void rejectIfEmpty(final String value, final String message) throws An
* @return the resource as {@link InputStream}
* @throws IOException when an error occurs during resource loading
*/
protected InputStream getResourceAsStream(final String resource) throws IOException {
InputStream getResourceAsStream(final String resource) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can still as protected. Why do we need to make it package private?

InputStream resourceAsStream;
if (resource.startsWith(FILE_RESOURCE_PREFIX)) {
resourceAsStream = new FileInputStream(extractPath(resource));
} else if (resource.startsWith(CLASSPATH_RESOURCE_PREFIX)) {
resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(extractPath(resource));
resourceAsStream = ClassLoader.getSystemClassLoader().getResourceAsStream(extractPath(resource));
} else { // by default, it is a classpath resource
resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(resource);
resourceAsStream = ClassLoader.getSystemClassLoader().getResourceAsStream(resource);
}
return resourceAsStream;
}
Expand Down