Skip to content

Commit

Permalink
Improved: Use the ‘@OverRide’ annotation
Browse files Browse the repository at this point in the history
(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
  • Loading branch information
mthl committed Apr 27, 2019
1 parent 948d739 commit b37e315
Show file tree
Hide file tree
Showing 169 changed files with 925 additions and 249 deletions.
Expand Up @@ -209,6 +209,7 @@ public static Map<String, Object> calcBillingAccountBalance(DispatchContext dctx

@SuppressWarnings("serial")
protected static class BillingAccountComparator implements Comparator<Map<String, Object>>, Serializable{
@Override
public int compare(Map<String, Object> billingAccount1, Map<String, Object> billingAccount2) {
return ((BigDecimal)billingAccount1.get("accountBalance")).compareTo((BigDecimal)billingAccount2.get("accountBalance"));
}
Expand Down
Expand Up @@ -136,49 +136,60 @@ public void setIsDecorated(boolean isDecorated) {
}

// interface methods
@Override
public int size() {
return 1;
}

@Override
public boolean isEmpty() {
return false;
}

@Override
public boolean containsKey(Object object) {
return false;
}

@Override
public boolean containsValue(Object object) {
return false;
}

@Override
public Object put(Object name, Object value) {
Debug.logWarning("This [put()] method is not implemented in ContentMapFacade", module);
return null;
}

@Override
public Object remove(Object object) {
Debug.logWarning("This [remove()] method is not implemented in ContentMapFacade", module);
return null;
}

@Override
public void putAll(Map<?, ?> map) {
Debug.logWarning("This method [putAll()] is not implemented in ContentMapFacade", module);
}

@Override
public void clear() {
Debug.logWarning("This method [clear()] is not implemented in ContentMapFacade", module);
}

@Override
public Set<Object> keySet() {
return UtilGenerics.checkSet(mapKeySet);
}

@Override
public Collection<Object> values() {
Debug.logWarning("This method [values()] is not implemented in ContentMapFacade", module);
return null;
}

@Override
public Set<Map.Entry<Object, Object>> entrySet() {
Debug.logWarning("This method [entrySet()] is not implemented in ContentMapFacade", module);
return null;
Expand Down Expand Up @@ -215,6 +226,7 @@ public void setDecoratedContent(ContentMapFacade decoratedContent) {
}

// implemented get method
@Override
public Object get(Object obj) {
if (!(obj instanceof String)) {
Debug.logWarning("Key parameters must be a string", module);
Expand Down Expand Up @@ -354,50 +366,61 @@ public String toString() {
}

abstract class AbstractInfo implements Map<Object, Object> {
@Override
public int size() {
return 1;
}

@Override
public boolean isEmpty() {
return false;
}

@Override
public boolean containsKey(Object object) {
return false;
}

@Override
public boolean containsValue(Object object) {
return false;
}

@Override
public Object put(Object name, Object value) {
Debug.logWarning("This [put()] method is not implemented in ContentMapFacade.AbstractInfo", module);
return null;
}

@Override
public Object remove(Object object) {
Debug.logWarning("This [remove()] method is not implemented in ContentMapFacade.AbstractInfo", module);
return null;
}

@Override
public void putAll(Map<?, ?> map) {
Debug.logWarning("This method [putAll()] is not implemented in ContentMapFacade.AbstractInfo", module);
}

@Override
public void clear() {
Debug.logWarning("This method [clear()] is not implemented in ContentMapFacade.AbstractInfo", module);
}

@Override
public Set<Object> keySet() {
Debug.logWarning("This method [keySet()] is not implemented in ContentMapFacade.AbstractInfo", module);
return null;
}

@Override
public Collection<Object> values() {
Debug.logWarning("This method [values()] is not implemented in ContentMapFacade.AbstractInfo", module);
return null;
}

@Override
public Set<Map.Entry<Object, Object>> entrySet() {
Debug.logWarning("This method [entrySet()] is not implemented in ContentMapFacade.AbstractInfo", module);
return null;
Expand Down
Expand Up @@ -72,6 +72,7 @@ public List<String> list(String path) throws IOException {
return fileNames;
}

@Override
public void setBinaryTransfer(boolean isBinary) throws IOException {
if (isBinary) {
client.setFileType(FTP.BINARY_FILE_TYPE);
Expand All @@ -80,6 +81,7 @@ public void setBinaryTransfer(boolean isBinary) throws IOException {
}
}

@Override
public void setPassiveMode(boolean isPassive) {
if (isPassive) {
client.enterLocalPassiveMode();
Expand Down
Expand Up @@ -57,13 +57,15 @@ public class SimpleContentViewHandler extends AbstractViewHandler {
private String rootDir = null;
private String https = null;

@Override
public void init(ServletContext context) throws ViewHandlerException {
rootDir = context.getRealPath("/");
https = (String) context.getAttribute("https");
}
/**
* @see org.apache.ofbiz.webapp.view.ViewHandler#render(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {

LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
Expand Down
Expand Up @@ -76,6 +76,7 @@ public OrderContentWrapper(GenericValue order, HttpServletRequest request) {
this.mimeTypeId = EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", (Delegator) request.getAttribute("delegator"));
}

@Override
public StringUtil.StringWrapper get(String orderContentTypeId, String encoderType) {
return StringUtil.makeStringWrapper(getOrderContentAsText(order, orderContentTypeId, locale, mimeTypeId, order.getDelegator(), dispatcher, encoderType));
}
Expand Down
Expand Up @@ -322,6 +322,7 @@ private static class ProductByMapComparator implements Comparator<Object> {
this.descending = descending;
}

@Override
public int compare(java.lang.Object prod1, java.lang.Object prod2) {
int result = compareAsc((GenericEntity) prod1, (GenericEntity) prod2);

Expand Down
Expand Up @@ -83,6 +83,7 @@ public String get(String contentTypeId, boolean useCache, String encoderType) {
return getPartyContentAsText(party, contentTypeId, locale, mimeTypeId, party.getDelegator(), dispatcher, useCache, encoderType);
}

@Override
public StringUtil.StringWrapper get(String contentTypeId, String encoderType) {
return StringUtil.makeStringWrapper(get(contentTypeId, true, encoderType));
}
Expand Down
Expand Up @@ -40,9 +40,7 @@ public class CatalogUrlSeoFilter extends CatalogUrlFilter {
protected String defaultLocaleString = null;
protected String redirectUrl = null;

/**
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
Expand Down
Expand Up @@ -79,6 +79,7 @@ public CategoryContentWrapper(GenericValue productCategory, HttpServletRequest r
this.mimeTypeId = EntityUtilProperties.getPropertyValue("content", "defaultMimeType", "text/html; charset=utf-8", (Delegator) request.getAttribute("delegator"));
}

@Override
public StringUtil.StringWrapper get(String prodCatContentTypeId, String encoderType) {
return StringUtil.makeStringWrapper(getProductCategoryContentAsText(productCategory, prodCatContentTypeId, locale, mimeTypeId, productCategory.getDelegator(), dispatcher, encoderType));
}
Expand Down
Expand Up @@ -40,9 +40,7 @@ public ControlServlet() {
super();
}

/**
* @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
*/
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);

Expand Down
Expand Up @@ -66,6 +66,7 @@ public class SeoContextFilter implements Filter {
private String errorCode = "";
private List<String> allowedPathList = new ArrayList<>();

@Override
public void init(FilterConfig config) throws ServletException {
this.config = config;
allowedPaths = config.getInitParameter("allowedPaths");
Expand All @@ -89,9 +90,7 @@ public void init(FilterConfig config) throws ServletException {
}
}

/**
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
Expand Down
Expand Up @@ -50,9 +50,7 @@ public SeoControlServlet() {
super();
}

/**
* @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
*/
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);

Expand All @@ -72,6 +70,7 @@ public void init(ServletConfig config) throws ServletException {
SeoConfigUtil.init();
}

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String uri = URLEncoder.encode(request.getRequestURI(), "UTF-8");
if (request.getAttribute(REQUEST_IN_ALLOW_LIST) != null || request.getAttribute("_jsp_" + uri) != null) {
Expand Down
Expand Up @@ -88,14 +88,17 @@ public Writer getWriter(Writer out, @SuppressWarnings("rawtypes") Map args)

return new Writer(out) {

@Override
public void write(char[] cbuf, int off, int len) throws IOException {
buf.append(cbuf, off, len);
}

@Override
public void flush() throws IOException {
out.flush();
}

@Override
public void close() throws IOException {
try {
Environment env = Environment.getCurrentEnvironment();
Expand Down
Expand Up @@ -71,14 +71,17 @@ public Writer getWriter(Writer out, @SuppressWarnings("rawtypes") Map args) {

return new Writer(out) {

@Override
public void write(char cbuf[], int off, int len) {
buf.append(cbuf, off, len);
}

@Override
public void flush() throws IOException {
out.flush();
}

@Override
public void close() throws IOException {
try {
Environment env = Environment.getCurrentEnvironment();
Expand Down
Expand Up @@ -71,14 +71,17 @@ public Writer getWriter(final Writer out, @SuppressWarnings("rawtypes") Map args

return new Writer(out) {

@Override
public void write(char cbuf[], int off, int len) {
buf.append(cbuf, off, len);
}

@Override
public void flush() throws IOException {
out.flush();
}

@Override
public void close() throws IOException {
try {
Environment env = Environment.getCurrentEnvironment();
Expand Down
Expand Up @@ -86,6 +86,7 @@ public String get(String workEffortContentId, boolean useCache, String encoderTy
* @param contentTypeId Type of content to return
* @return String containing the content data
*/
@Override
public StringUtil.StringWrapper get(String contentTypeId, String encoderType) {
return StringUtil.makeStringWrapper(get(contentTypeId, true, encoderType));
}
Expand Down
Expand Up @@ -59,6 +59,7 @@ public ICalHandlerFactory() {
handlerMap.put("UNLOCK", ICalHandlerFactory::doNothing);
}

@Override
public RequestHandler getHandler(String method) {
RequestHandler handler = handlerMap.get(method);
if (handler == null) {
Expand Down
Expand Up @@ -59,14 +59,17 @@ public ComponentResourceHandler(String componentName, String loaderName, String
}
}

@Override
public String getLoaderName() {
return this.loaderName;
}

@Override
public String getLocation() {
return this.location;
}

@Override
public Document getDocument() throws GenericConfigException {
try {
return UtilXml.readXmlDocument(this.getStream(), this.getFullLocation(), true);
Expand All @@ -75,18 +78,22 @@ public Document getDocument() throws GenericConfigException {
}
}

@Override
public InputStream getStream() throws GenericConfigException {
return ComponentConfig.getStream(componentName, loaderName, location);
}

@Override
public URL getURL() throws GenericConfigException {
return ComponentConfig.getURL(componentName, loaderName, location);
}

@Override
public boolean isFileResource() throws GenericConfigException {
return ComponentConfig.isFileResourceLoader(componentName, loaderName);
}

@Override
public String getFullLocation() throws GenericConfigException {
return ComponentConfig.getFullLocation(componentName, loaderName, location);
}
Expand Down

0 comments on commit b37e315

Please sign in to comment.