Improved: Use the ‘@Override’ annotation

(OFBIZ-10939)

The ‘@Override’ annotation helps readers understand that the method at
hand is overriding a super class or implementing an interface.
Additionally it allows the compiler to check if the methods annotated
with ‘@Override’ are actually implementing an abstract method.

Using that annotation makes ‘@see foo.bar.ParentClass#myMethod’
comments useless, so those they have been removed for the newly
annotated methods.

Thanks Jacques Le Roux and Swapnil M Mane for acknowledging the commit.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858295 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mathieu Lirzin
2019-04-27 19:34:25 +00:00
parent 948d73946e
commit b37e315aef
169 changed files with 925 additions and 249 deletions
@@ -132,6 +132,7 @@ public final class AuthHelper {
private static ClassLoader getContextClassLoader() {
return AccessController.doPrivileged(
new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
ClassLoader cl = null;
try {
@@ -64,6 +64,7 @@ public class AuthenticationComparator implements Comparator<Authenticator> {
* @throws ClassCastException if the arguments' types prevent them from
* being compared by this Comparator.
*/
@Override
public int compare(Authenticator a1, Authenticator a2) {
int comp = Float.compare(a1.getWeight(), a2.getWeight());
if (comp != 0) {
@@ -41,6 +41,7 @@ public class TestFailAuthenticator implements Authenticator {
*
* @param dispatcher The LocalDispatcher to use for this Authenticator
*/
@Override
public void initialize(LocalDispatcher dispatcher) {
this.dispatcher = dispatcher;
this.delegator = dispatcher.getDelegator();
@@ -57,6 +58,7 @@ public class TestFailAuthenticator implements Authenticator {
* @throws org.apache.ofbiz.common.authentication.api.AuthenticatorException
* when a fatal error occurs during authentication
*/
@Override
public boolean authenticate(String username, String password, boolean isServiceAuth) throws AuthenticatorException {
Debug.logInfo(this.getClass().getName() + " Authenticator authenticate() -- returning false", module);
return false;
@@ -69,6 +71,7 @@ public class TestFailAuthenticator implements Authenticator {
* @throws org.apache.ofbiz.common.authentication.api.AuthenticatorException
* when logout fails
*/
@Override
public void logout(String username) throws AuthenticatorException {
Debug.logInfo(this.getClass().getName() + " Authenticator logout()", module);
}
@@ -80,6 +83,7 @@ public class TestFailAuthenticator implements Authenticator {
* @throws org.apache.ofbiz.common.authentication.api.AuthenticatorException
* user synchronization fails
*/
@Override
public void syncUser(String username) throws AuthenticatorException {
Debug.logInfo(this.getClass().getName() + " Authenticator syncUser()", module);
// no user info to sync
@@ -94,6 +98,7 @@ public class TestFailAuthenticator implements Authenticator {
* @throws org.apache.ofbiz.common.authentication.api.AuthenticatorException
* when update password fails
*/
@Override
public void updatePassword(String username, String password, String newPassword) throws AuthenticatorException {
Debug.logInfo(this.getClass().getName() + " Authenticator updatePassword()", module);
}
@@ -103,6 +108,7 @@ public class TestFailAuthenticator implements Authenticator {
*
* @return the weight of this Authenticator
*/
@Override
public float getWeight() {
return 1;
}
@@ -112,6 +118,7 @@ public class TestFailAuthenticator implements Authenticator {
*
* @return true if the user record is copied to the OFB database
*/
@Override
public boolean isUserSynchronized() {
Debug.logInfo(this.getClass().getName() + " Authenticator isUserSynchronized()", module);
return true;
@@ -122,6 +129,7 @@ public class TestFailAuthenticator implements Authenticator {
*
* @return true if this is expected to be the only Authenticator
*/
@Override
public boolean isSingleAuthenticator() {
Debug.logInfo(this.getClass().getName() + " Authenticator isSingleAuthenticator()", module);
return false;
@@ -132,6 +140,7 @@ public class TestFailAuthenticator implements Authenticator {
*
* @return true if the Authenticator is enabled
*/
@Override
public boolean isEnabled() {
return false;
}
@@ -716,18 +716,22 @@ public class EmailServices {
contentArray.close();
}
@Override
public String getContentType() {
return contentType == null ? "application/octet-stream" : contentType;
}
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(contentArray.toByteArray());
}
@Override
public String getName() {
return "stringDatasource";
}
@Override
public OutputStream getOutputStream() throws IOException {
throw new IOException("Cannot write to this read-only resource");
}
@@ -743,18 +747,22 @@ public class EmailServices {
this.contentArray = content.clone();
}
@Override
public String getContentType() {
return contentType == null ? "application/octet-stream" : contentType;
}
@Override
public InputStream getInputStream() {
return new ByteArrayInputStream(contentArray);
}
@Override
public String getName() {
return "ByteArrayDataSource";
}
@Override
public OutputStream getOutputStream() throws IOException {
throw new IOException("Cannot write to this read-only resource");
}
@@ -114,6 +114,7 @@ public final class ScriptHelperImpl implements ScriptHelper {
this.ctxHelper = new ContextHelper(context);
}
@Override
public Map<String, ? extends Object> createServiceMap(String serviceName, Map<String, ? extends Object> inputMap) throws ScriptException {
Assert.notNull("serviceName", serviceName, "inputMap", inputMap);
Map<String, Object> toMap = new HashMap<>();
@@ -154,6 +155,7 @@ public final class ScriptHelperImpl implements ScriptHelper {
}
}
@Override
public List<Map<String, Object>> findList(String entityName, Map<String, ? extends Object> fields) throws ScriptException {
try {
return UtilGenerics.checkList(ctxHelper.getDelegator().findByAnd(entityName, fields, null, false));
@@ -164,10 +166,12 @@ public final class ScriptHelperImpl implements ScriptHelper {
}
}
@Override
public Map<String, Object> findOne(String entityName) throws ScriptException {
return findOne(entityName, null, EMPTY_ARGS);
}
@Override
public Map<String, Object> findOne(String entityName, Map<String, ? extends Object> fields, Map<String, ? extends Object> args) throws ScriptException {
Assert.notNull("entityName", entityName);
if (args == null) {
@@ -183,33 +187,40 @@ public final class ScriptHelperImpl implements ScriptHelper {
return runFindByPrimaryKey(modelEntity, ctxHelper, useCache, autoFieldMap, fields, selectFieldList);
}
@Override
public void logError(String message) {
String expandedMessage = ctxHelper.expandString(message);
Debug.logError("[".concat(ctxHelper.getScriptName()).concat("] ").concat(expandedMessage), module);
}
@Override
public void logInfo(String message) {
String expandedMessage = ctxHelper.expandString(message);
Debug.logInfo("[".concat(ctxHelper.getScriptName()).concat("] ").concat(expandedMessage), module);
}
@Override
public void logWarning(String message) {
String expandedMessage = ctxHelper.expandString(message);
Debug.logWarning("[".concat(ctxHelper.getScriptName()).concat("] ").concat(expandedMessage), module);
}
@Override
public Map<String, Object> makeValue(String entityName) throws ScriptException {
return ctxHelper.getDelegator().makeValidValue(entityName);
}
@Override
public Map<String, Object> makeValue(String entityName, Map<String, Object> fields) throws ScriptException {
return ctxHelper.getDelegator().makeValidValue(entityName, fields);
}
@Override
public Map<String, ? extends Object> runService(String serviceName, Map<String, ? extends Object> inputMap) throws ScriptException {
return runService(serviceName, inputMap, EMPTY_ARGS);
}
@Override
public Map<String, ? extends Object> runService(String serviceName, Map<String, ? extends Object> inputMap, Map<String, ? extends Object> args) throws ScriptException {
Assert.notNull("serviceName", serviceName, "args", args);
boolean includeUserLogin = !"false".equals(args.get("includeUserLoginStr"));