Contributing

Guidelines for contributing to this project.

Pull requests have some guidelines before being approved.

Code Guidelines

  1. Any new addition of a variable must include final

  2. Static-abuse: static should only be used if a class requires a helper method, such as merging strings or parsing a string to an object. There is no other reason to use static.

  3. Any new addition of a method must include:

    • Annotations: If a method returns something, mark it as either @NotNull or @Nullabledepending on the outcome.

    • Documentation: Explain what this method does, what it returns, what it MAY throw, what params are needed.

    • Parameters: Parameters will need the @NotNull or @Nullable annotation, if the parameter is a primitive you must use final.

  4. You cannot "optimize" a method / change internal code unless it is stated that you can make a PR to clean it up, there is very few points of this within the Wrapper, so only use contributions for new features and follow the guidelines.

Java is not C#

When talking about "Java is not C#", we are talking about curly braces & method/variable names.

Bad:

if (condition) 
{
    System.out.println("Condition is true!")
}

final String Identifier = "";

public String RemoveSpaceFromString(@NotNull String input) 
{
    return input.trim();
} 

Good:

if (condition) {
    System.out.println("Condition is true!")
}

final String identifier = "";

public String removeSpaceFromString(@NotNull String input) {
    return input.trim();
}

No curly braces in one-line returns

Bad:

final boolean condition = validateCondition(...)
if (condition) {
    return;
}

Good:

final boolean condition = validateCondition(...)
if (condition) return;

Invokation of a method

When invoking a method and the method depends on another method in the class, you must always use this.

Bad:

public class SomeClass {
    public void doAction(@NotNull String input) {
        final String input = removeSpaceFromString(input)
        ...
    }
    
    @NotNull
    public String removeSpaceFromString(@NotNull String input) {
        return input.trim();
    }
}

Good:

public class SomeClass {
    public void doAction(@NotNull String input) {
        final String input = this.removeSpaceFromString(input)
        ...
    }
    
    @NotNull
    public String removeSpaceFromString(@NotNull String input) {
        return input.trim();
    }
}

Re-use of variables

Bad:

public class SomeClass {
    public void doAction(@NotNull ClassThatHasAType clazz) {
        if (clazz.getType() == null) return;
        final boolean outcome = clazz.getType().execute();
        if (!outcome) return;
        clazz.getType().attemptAgain();
    }
}

Good:

public class SomeClass {
    public void doAction(@NotNull ClassThatHasAType clazz) {
        final SomeType someType = clazz.getType();
        if (someType == null) return;
        final boolean outcome = someType.execute();
        if (!outcome) return;
        someType.attemptAgain();
    }
}

Nesting

Bad:

final boolean passses = ...;
final boolean thisPasses = ...;
final boolean andThis = ...;

if (passes) {
   if (thisPasses) {
      if (andThis) {
         this.executeThis();
      }
   }
}

Good:

final boolean passses = ...;
final boolean thisPasses = ...;
final boolean andThis = ...;

if (!passes) return; // or if in loop continue to not break functionality
if (!thisPasses) return;
if (!andThis) return;

this.executeThis();

Last updated

Was this helpful?