Package rsb.util

Class OutputObjectComparer

java.lang.Object
rsb.util.OutputObjectComparer

public class OutputObjectComparer extends Object
  • Constructor Details

    • OutputObjectComparer

      public OutputObjectComparer(Object object, Integer[] modifiersToInclude, String[] returnTypesToInclude, String[] returnTypesToIgnore, String[] stringsToIgnoreInName, Integer[] parameterConstraints)
      Creates an outputobjectcomparer with the given parameters
      Parameters:
      object - the object to compare methods of
      parameterConstraints - the numbers of parameters to look for (usually going to just hold zero)
      modifiersToInclude - the modifiers of the methods to include when checking the methods
      returnTypesToInclude - the return types of the methods to include when checking the methods
      returnTypesToIgnore - the return types of the methods to ignore when checking the methods
      stringsToIgnoreInName - the strings in the names of methods to ignore when checking the methods
  • Method Details

    • getListOfMethodOutputsEx

      public HashMap<String,Object> getListOfMethodOutputsEx(Parameters[] param, Method... conditionals)
      Gets the output list based on this objects variables and parameters allowing one to add extra information to the key. Additionally one may pass a method that performs a conditional statement to allow further sorting of the array.

      IE one should make a method in the class they are calling this from then use reflection and get the method from that class like so: exampleClass.class.getMethod("conditional1", int.class)

      Parameters:
      param - parameter array to decide what to values to return in the key
      conditionals - the conditional values to use to impact the output
      Returns:
      the list of keys and outputs of the object's methods respective to the parameters
    • getListOfFieldOutputsEx

      public HashMap<String,Object> getListOfFieldOutputsEx(Parameters[] param, Method... conditionals)
      Gets the output list based on this objects variables and parameters allowing one to add extra information to the key. Additionally one may pass a method that performs a conditional statement to allow further sorting of the array.

      IE one should make a method in the class they are calling this from then use reflection and get the method from that class like so: exampleClass.class.getMethod("conditional1", int.class)

      Parameters:
      param - parameter array to decide what to values to return in the key
      conditionals - the conditional values to use to impact the output
      Returns:
      the list of keys and outputs of the object's methods respective to the parameters
    • getListOfMethodOutputsEx

      public static HashMap<String,Object> getListOfMethodOutputsEx(Object objectToInvoke, Integer[] modifiersToInclude, String[] returnTypesToInclude, String[] returnTypesToIgnore, String[] namesToIgnore, Integer[] parameterConstraints, Parameters... param)
      Returns a hashmap of given parameters for the keys and objects of any method for the values and also respective to the parameters supplied
      Parameters:
      objectToInvoke - the object to check
      parameterConstraints - an array of parameter counts to allow
      modifiersToInclude - the modifiers of the method to include IE public static final ect
      returnTypesToInclude - the return types to include
      returnTypesToIgnore - the return types to ignore
      namesToIgnore - the names/strings in the names to ignore
      param - parameter array to decide what to values to return in the key
      Returns:
      the list of names and outputs of the object's methods respective to the parameters
    • getListOfMethodOutputs

      public HashMap<String,Object> getListOfMethodOutputs()
      Returns a hashmap of names and objects of any method with no parameters and respective to the parameters supplied
      Returns:
      the list of names and outputs of the object's methods respective to the parameters
    • getListOfMethodOutputs

      public static HashMap<String,Object> getListOfMethodOutputs(Object objectToInvoke, Class<?> classToCheck, Integer[] modifiersToInclude, String[] returnTypesToInclude, String[] returnTypesToIgnore, String[] namesToIgnore, Integer[] parameterConstraints)
      Returns a hashmap of names and objects of any method with no parameters and respective to the parameters supplied
      Parameters:
      objectToInvoke - the object to check
      classToCheck - the class of the object to invoke methods on
      parameterConstraints - an array of parameter counts to allow
      modifiersToInclude - the modifiers of the method to include IE public static final ect
      returnTypesToInclude - the return types to include
      returnTypesToIgnore - the return types to ignore
      namesToIgnore - the names/strings in the names to ignore
      Returns:
      the list of names and outputs of the object's methods respective to the parameters
    • checkForMatching

      public ArrayList<String> checkForMatching(HashMap<String,Object> compareTo)
      Creates a hashmap of strings and object outputs to then compares to another hashmap of strings and object outputs to determine the differences and returns a list of the strings and objects that differ between the two
      Parameters:
      compareTo - The second hashmap to compare against for collisions
      Returns:
      the names of the outputs that did not match
    • checkForTypeAndNoMatch

      public boolean checkForTypeAndNoMatch(Object firstObject, Object secondObject)
      Checks the first objects type and then compares it to the second object which should also be the same type
      Parameters:
      firstObject - the first object to check
      secondObject - the object to compare to
      Returns:
      false unless they match
    • checkForMatchingMethodOutputsEx

      public HashMap<String,Object> checkForMatchingMethodOutputsEx(HashMap<String,Object> compareTo, Parameters... param)
      Creates a hashmap of strings and object outputs to then compares to another hashmap of strings and object outputs to determine the differences and returns a hashmap of the strings and objects that differ between the two
      Parameters:
      compareTo - The second hashmap to compare against for collisions
      param - The parameters to use as a filter on the second hashmap
      Returns:
      the names of the outputs that did not match
    • convertToStringArrayStyle

      public static String convertToStringArrayStyle(ArrayList<?> stringToConvert)
      Converts the given ArrayList containing strings to a string with the style of a String[] eg String output = "{"item1", "item2", "item3", "item4"}"
      Parameters:
      stringToConvert - ArrayList to convert to a string
      Returns:
      A string comprised of the contents of the ArrayList
    • convertToStringArrayStyle

      public static String convertToStringArrayStyle(List<?> stringToConvert)
      Converts the given ArrayList containing strings to a string with the style of a String[] eg String output = "{"item1", "item2", "item3", "item4"}"
      Parameters:
      stringToConvert - List to convert to a string
      Returns:
      A string comprised of the contents of the List
    • convertToStringArrayStyleEx

      public static String convertToStringArrayStyleEx(HashMap<String,Object> stringObjectHashMap, Parameters... param)
      Returns everything in the hashmap as a String[] styled string
      Parameters:
      stringObjectHashMap - the hashmap to convert
      param - The parameters to use as a filter on the second hashmap
      Returns:
      the string containing all the data in the hashmap as a string
    • getMethodOuputsEx

      public String getMethodOuputsEx(Parameters[] param, Method... methods)
      Returns a string of as much method outputs as the parameters passed for each object as well as allowing the passing of conditional methods to further sort the results
      Parameters:
      param - the parameter array to decide what to values to return in the key
      methods - the methods to allow further filtering of the method outputs
      Returns:
      all the designated output based on the passed parameters for all objects
    • getMethodOuputsEx

      public String getMethodOuputsEx(Parameters... param)
      Returns a string of as much method outputs as the parameters passed for each object
      Parameters:
      param - the parameter array to decide what to values to return in the key
      Returns:
      all the designated output based on the passed parameters for all objects
    • getFieldOutputEx

      public String getFieldOutputEx(Parameters... param)
      Returns a string of as much field values as the parameters passed for each object
      Parameters:
      param - the parameter array to decide what to values to return in the key
      Returns:
      all the designated output based on the passed parameters for all objects
    • getFieldOutputEx

      public String getFieldOutputEx(Parameters[] param, Method... method)
      Returns a string of as much field values as the parameters passed for each object as well as allowing the passing of conditional methods to further sort the results
      Parameters:
      param - the parameter array to decide what to values to return in the key
      method - the methods to allow further filtering of the method outputs
      Returns:
      all the designated output based on the passed parameters for all objects
    • getNamesOfMethods

      public String getNamesOfMethods()
      Gets the names of the methods into a readable string
      Returns:
      the names of the objects methods
    • getObjectsOfMethods

      public String getObjectsOfMethods()
      Gets the outputs of the methods into a readable string
      Returns:
      the outputs of the objects methods
    • unpack

      public static Object[] unpack(Object object)
      Returns the object as an array example usage: String[] names = new String[]{"rb", "xz", "ux", "pt", "ye"}; for (String name : names) { try { Method method = player.getClass().getMethod(name); Object[] output = OutputObjectComparer.unpack(method.invoke(player)); log.debug("Name: " + name); for (int i = 0; i (less than) output.length; i++) { log.debug("Output:" + (int) output[i]); } log.debug("\n\n"); } catch (Exception e) { } }
      Parameters:
      object - the object to convert
      Returns:
      the object as an array
    • getStringsToIgnoreInName

      public String[] getStringsToIgnoreInName()
    • setStringsToIgnoreInName

      public void setStringsToIgnoreInName(String[] stringsToIgnoreInName)
    • getTypesToIgnore

      public String[] getTypesToIgnore()
    • setTypesToIgnore

      public void setTypesToIgnore(String[] typesToIgnore)
    • getModifiersToInclude

      public Integer[] getModifiersToInclude()
    • setModifiersToInclude

      public void setModifiersToInclude(Integer[] modifiersToInclude)
    • getObject

      public Object getObject()
    • setObject

      public void setObject(Object object)
    • getTypesToInclude

      public String[] getTypesToInclude()
    • setTypesToInclude

      public void setTypesToInclude(String[] typesToInclude)
    • getParameterConstraints

      public Integer[] getParameterConstraints()
    • setParameterConstraints

      public void setParameterConstraints(Integer[] parameterConstraints)