protected Map<Method, Object> getConsoleMethods() {
    if (methods != null)
      return methods;

    // search for declared command collections
    final Iterator<OConsoleCommandCollection> ite = ServiceLoader.load(OConsoleCommandCollection.class).iterator();
    final Collection<Object> candidates = new ArrayList<Object>();
    candidates.add(this);
    while (ite.hasNext()) {
      try {
        // make a copy and set it's context
        final OConsoleCommandCollection cc = ite.next().getClass().newInstance();
        cc.setContext(this);
        candidates.add(cc);
      } catch (InstantiationException ex) {
        Logger.getLogger(OConsoleApplication.class.getName()).log(Level.WARNING, ex.getMessage());
      } catch (IllegalAccessException ex) {
        Logger.getLogger(OConsoleApplication.class.getName()).log(Level.WARNING, ex.getMessage());
      }
    }

    methods = new TreeMap<Method, Object>(new Comparator<Method>() {
      public int compare(Method o1, Method o2) {
        final ConsoleCommand ann1 = o1.getAnnotation(ConsoleCommand.class);
        final ConsoleCommand ann2 = o2.getAnnotation(ConsoleCommand.class);

        if (ann1 != null && ann2 != null) {
          if (ann1.priority() != ann2.priority())
            // PRIORITY WINS
            return ann1.priority() - ann2.priority();
        }

        int res = o1.getName().compareTo(o2.getName());
        if (res == 0)
          res = o1.toString().compareTo(o2.toString());
        return res;
      }
    });

    for (final Object candidate : candidates) {
      final Method[] classMethods = candidate.getClass().getMethods();

      for (Method m : classMethods) {
        if (Modifier.isAbstract(m.getModifiers()) || Modifier.isStatic(m.getModifiers()) || !Modifier.isPublic(m.getModifiers())) {
          continue;
        }
        if (m.getReturnType() != Void.TYPE) {
          continue;
        }
        methods.put(m, candidate);
      }
    }
    return methods;
  }
protected Map<Method, Object> getConsoleMethods() {
    if (methods != null)
      return methods;

    
    final Iterator<OConsoleCommandCollection> ite = ServiceLoader.load(OConsoleCommandCollection.class).iterator();
    final Collection<Object> candidates = new ArrayList<Object>();
    candidates.add(this);
    while (ite.hasNext()) {
      try {
        
        final OConsoleCommandCollection cc = ite.next().getClass().newInstance();
        cc.setContext(this);
        candidates.add(cc);
      } catch (InstantiationException ex) {
        Logger.getLogger(OConsoleApplication.class.getName()).log(Level.WARNING, ex.getMessage());
      } catch (IllegalAccessException ex) {
        Logger.getLogger(OConsoleApplication.class.getName()).log(Level.WARNING, ex.getMessage());
      }
    }

    methods = new TreeMap<Method, Object>(new Comparator<Method>() {
      public int compare(Method o1, Method o2) {
        final ConsoleCommand ann1 = o1.getAnnotation(ConsoleCommand.class);
        final ConsoleCommand ann2 = o2.getAnnotation(ConsoleCommand.class);

        if (ann1 != null && ann2 != null) {
          if (ann1.priority() != ann2.priority())
            
            return ann1.priority() - ann2.priority();
        }

        int res = o1.getName().compareTo(o2.getName());
        if (res == 0)
          res = o1.toString().compareTo(o2.toString());
        return res;
      }
    });

    for (final Object candidate : candidates) {
      final Method[] classMethods = candidate.getClass().getMethods();

      for (Method m : classMethods) {
        if (Modifier.isAbstract(m.getModifiers()) || Modifier.isStatic(m.getModifiers()) || !Modifier.isPublic(m.getModifiers())) {
          continue;
        }
        if (m.getReturnType() != Void.TYPE) {
          continue;
        }
        methods.put(m, candidate);
      }
    }
    return methods;
  }
protected Map < Method , Object > getConsoleMethods ( ) { if ( methods != null ) return methods ; // search for declared command collections final Iterator < OConsoleCommandCollection > ite = ServiceLoader . load ( OConsoleCommandCollection . class ) . iterator ( ) ; final Collection < Object > candidates = new ArrayList < Object > ( ) ; candidates . add ( this ) ; while ( ite . hasNext ( ) ) { try { // make a copy and set it's context final OConsoleCommandCollection cc = ite . next ( ) . getClass ( ) . newInstance ( ) ; cc . setContext ( this ) ; candidates . add ( cc ) ; } catch ( InstantiationException ex ) { Logger . getLogger ( OConsoleApplication . class . getName ( ) ) . log ( Level . WARNING , ex . getMessage ( ) ) ; } catch ( IllegalAccessException ex ) { Logger . getLogger ( OConsoleApplication . class . getName ( ) ) . log ( Level . WARNING , ex . getMessage ( ) ) ; } } methods = new TreeMap < Method , Object > ( new Comparator < Method > ( ) { public int compare ( Method o1 , Method o2 ) { final ConsoleCommand ann1 = o1 . getAnnotation ( ConsoleCommand . class ) ; final ConsoleCommand ann2 = o2 . getAnnotation ( ConsoleCommand . class ) ; if ( ann1 != null && ann2 != null ) { if ( ann1 . priority ( ) != ann2 . priority ( ) ) // PRIORITY WINS return ann1 . priority ( ) - ann2 . priority ( ) ; } int res = o1 . getName ( ) . compareTo ( o2 . getName ( ) ) ; if ( res == 0 ) res = o1 . toString ( ) . compareTo ( o2 . toString ( ) ) ; return res ; } } ) ; for ( final Object candidate : candidates ) { final Method [ ] classMethods = candidate . getClass ( ) . getMethods ( ) ; for ( Method m : classMethods ) { if ( Modifier . isAbstract ( m . getModifiers ( ) ) || Modifier . isStatic ( m . getModifiers ( ) ) || ! Modifier . isPublic ( m . getModifiers ( ) ) ) { continue ; } if ( m . getReturnType ( ) != Void . TYPE ) { continue ; } methods . put ( m , candidate ) ; } } return methods ; }
Returns a map of all console method and the object they can be called on.

@return Map&lt;Method,Object&gt;
Returns a map of all console method and the object they can be called on .