예제 #1
0
 private void sortPotentialOption(Class<? extends Option> probableOption) {
   Class superClass = probableOption.getSuperclass();
   while (true) {
     if (superClass == Pattern.class) {
       patterns.add(probableOption);
       break;
     }
     if (superClass == Condition.class) {
       conditions.add(probableOption);
       break;
     }
     if (superClass == Action.class) {
       actions.add(probableOption);
       break;
     }
     if (superClass == Requirement.class) {
       requirements.add(probableOption);
       break;
     }
     if (superClass == Object.class) {
       break;
     }
     superClass = superClass.getSuperclass();
   }
 }
예제 #2
0
 @SuppressWarnings("unchecked")
 private void sortPotentialOptions() throws ClassNotFoundException {
   for (String potentialOption : potentialOptions) {
     Class<? extends Option> probableOption =
         (Class<? extends Option>) Class.forName(potentialOption);
     sortPotentialOption(probableOption);
   }
 }
예제 #3
0
 private void addOptionToProvider(Class<? extends Option> option) throws Exception {
   Option optionInstance = option.newInstance();
   String description = optionInstance.getDescription();
   if (description == null) {
     description = "";
   }
   ContentValues values = new ContentValues();
   values.put(OptionsContract.OptionsEntry.COLUMN_NAME, option.getName());
   values.put(OptionsContract.OptionsEntry.COLUMN_DESCRIPTION, description);
   values.put(OptionsContract.OptionsEntry.COLUMN_PACKAGE_NAME, "us.bridgeses.minder");
   values.put(OptionsContract.OptionsEntry.COLUMN_TYPE, optionInstance.getOptionType().name());
   values.put(OptionsContract.OptionsEntry.COLUMN_PICKER, "");
   values.put(OptionsContract.OptionsEntry.COLUMN_TARGET, "");
   // TODO: Check if present; update if yes, insert if no
   resolver.insert(OptionsContract.OptionsEntry.CONTENT_URI, values);
   // OptionsContract.OptionsEntry.COLUMN_NAME + " = ?",
   // new String[] {option.getSimpleName()});
 }