package io.github.skepter.skepbot.modules;

import java.util.concurrent.ThreadLocalRandom;

public class Magic8 extends Module {

	String[] responses = { "It is certain", "It is decidedly so", "Without a doubt", "Yes definitely",
			"You may rely on it", "As I see it, yes", "Most likely", "Outlook good", "Yes", "Signs point to yes",
			"Reply hazy try again", "Ask again later", "Better not tell you now", "Cannot predict now",
			"Concentrate and ask again", "Don't count on it", "My reply is no", "My sources say no",
			"Outlook not so good", "Very doubtful" };

	public Magic8() {
		super(PatternType.STARTS_WITH, "magic8");
	}

	@Override
	public boolean extraConditions() {
		return input.endsWith("?");
	}

	@Override
	public String output() {
		return responses[ThreadLocalRandom.current().nextInt(0, responses.length)];
	}

}

package io.github.skepter.skepbot.modules;

import java.util.concurrent.ThreadLocalRandom;

public class Magic8 extends Module {

	String[] responses = { "It is certain", "It is decidedly so", "Without a doubt", "Yes definitely",
			"You may rely on it", "As I see it, yes", "Most likely", "Outlook good", "Yes", "Signs point to yes",
			"Reply hazy try again", "Ask again later", "Better not tell you now", "Cannot predict now",
			"Concentrate and ask again", "Don't count on it", "My reply is no", "My sources say no",
			"Outlook not so good", "Very doubtful" };

	public Magic8() {
		super(PatternType.CONTAINS, "magic8", "magic 8");
	}

	@Override
	public boolean extraConditions() {
		return input.endsWith("?");
	}

	@Override
	public String output() {
		return responses[ThreadLocalRandom.current().nextInt(0, responses.length)];
	}

}

Update magic 8 ball syntax


/*******************************************************************************
 * Copyright (c) 2009 David A Carlson.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     David A Carlson (XMLmodeling.com) - initial API and implementation
 *
 * $Id$
 *******************************************************************************/
package org.openhealthtools.mdht.uml.common.notation;

import org.eclipse.uml2.uml.Element;

public interface INotationProvider {

	/**
	 * Returns the complete print string for displaying a model element.
	 */
	public String getPrintString(Element element);

	/**
	 * Returns only the annotations for a model element.
	 */
	public String getAnnotation(Element element);

}

/*******************************************************************************
 * Copyright (c) 2009 David A Carlson.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     David A Carlson (XMLmodeling.com) - initial API and implementation
 *
 * $Id$
 *******************************************************************************/
package org.openhealthtools.mdht.uml.common.notation;

import org.eclipse.uml2.uml.Element;

public interface INotationProvider {

	/**
	 * Returns the complete print string for displaying a model element.
	 */
	public String getPrintString(Element element);

	/**
	 * Returns only the annotations for a model element.
	 */
	public String getAnnotation(Element element);

	/**
	 * Returns an image for the model element, or null.
	 */
	public Object getElementImage(Element element);

	/**
	 * Returns an image for the annotations, or null.
	 */
	public Object getAnnotationImage(Element element);

}

Add support for notation images.


public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    	}
}
// public > all languages can access
// static > will run without making an instance
// void > will not return a value
// main > method name
/**
 *system > prefdefined class of methods/variables
 *out > stdout static variable
 *println > prints that line out
 */

 //Create all the the primitives with different values. C
 //oncatenate them into a string and print it to the screen so it will print: H3110 w0r1d 2.0 true

 public class Main2 {
    public static void main2(String[] args) {
        byte zero = 0;
        short a = 3;
        int b = 1;
        char d = ' ';
        float e = 2.0f;
        boolean f = true;
        String output = "H" + a + b + b + zero + d + "w" + zero + "r" + b + "d" + d + e + d + f;
        System.out.println(output);
    }
}


package org.ovirt.engine.core.searchbackend;

import org.ovirt.engine.core.common.businessentities.ProviderType;

public class ProviderConditionFieldAutoCompleter extends BaseConditionFieldAutoCompleter {

    public static final String NAME = "NAME";
    public static final String TYPE = "TYPE";
    public static final String DESCRIPTION = "DESCRIPTION";
    public static final String URL = "URL";

    public ProviderConditionFieldAutoCompleter() {
        // Building the basic verbs dict.
        mVerbs.add(NAME);
        mVerbs.add(TYPE);
        mVerbs.add(DESCRIPTION);
        mVerbs.add(URL);

        // Building the autoCompletion dict.
        buildCompletions();

        // Building the types dict.
        getTypeDictionary().put(NAME, String.class);
        getTypeDictionary().put(TYPE, ProviderType.class);
        getTypeDictionary().put(DESCRIPTION, String.class);
        getTypeDictionary().put(URL, String.class);

        // building the ColumnName dict.
        columnNameDict.put(NAME, "name");
        columnNameDict.put(TYPE, "provider_type");
        columnNameDict.put(DESCRIPTION, "description");
        columnNameDict.put(URL, "url");

        // Building the validation dict.
        buildBasicValidationTable();
    }

    @Override
    public IAutoCompleter getFieldRelationshipAutoCompleter(final String fieldName) {
        return StringConditionRelationAutoCompleter.INSTANCE;
    }

    @Override
    public IConditionValueAutoCompleter getFieldValueAutoCompleter(String fieldName) {
        if (TYPE.equals(fieldName)) {
            return new EnumValueAutoCompleter(ProviderType.class);
        }
        return null;
    }

}

package org.ovirt.engine.core.searchbackend;

import org.ovirt.engine.core.common.businessentities.ProviderType;

public class ProviderConditionFieldAutoCompleter extends BaseConditionFieldAutoCompleter {

    public static final String NAME = "NAME";
    public static final String TYPE = "TYPE";
    public static final String DESCRIPTION = "DESCRIPTION";
    public static final String URL = "URL";

    public ProviderConditionFieldAutoCompleter() {
        // Building the basic verbs dict.
        mVerbs.add(NAME);
        mVerbs.add(TYPE);
        mVerbs.add(DESCRIPTION);
        mVerbs.add(URL);

        // Building the autoCompletion dict.
        buildCompletions();

        // Building the types dict.
        getTypeDictionary().put(NAME, String.class);
        getTypeDictionary().put(TYPE, ProviderType.class);
        getTypeDictionary().put(DESCRIPTION, String.class);
        getTypeDictionary().put(URL, String.class);

        // building the ColumnName dict.
        columnNameDict.put(NAME, "name");
        columnNameDict.put(TYPE, "provider_type");
        columnNameDict.put(DESCRIPTION, "description");
        columnNameDict.put(URL, "url");

        // Building the validation dict.
        buildBasicValidationTable();
    }

    @Override
    public IAutoCompleter getFieldRelationshipAutoCompleter(final String fieldName) {
        return StringConditionRelationAutoCompleter.INSTANCE;
    }

    @Override
    public IConditionValueAutoCompleter getFieldValueAutoCompleter(String fieldName) {
        if (TYPE.equals(fieldName)) {
            return new EnumNameAutoCompleter(ProviderType.class);
        }
        return null;
    }

}

Use enum name to search providers


package cpw.mods.fml.common;

import java.util.logging.Level;
import java.util.logging.Logger;

public class FMLLog
{
    private static cpw.mods.fml.relauncher.FMLRelaunchLog coreLog = cpw.mods.fml.relauncher.FMLRelaunchLog.log;

    public static void log(Level level, String format, Object... data)
    {
        coreLog.log(level, String.format(format, data));
    }

    public static void log(Level level, Throwable ex, String format, Object... data)
    {
        coreLog.log(level, String.format(format, data), ex);
    }

    public static void severe(String format, Object... data)
    {
        log(Level.SEVERE, format, data);
    }

    public static void warning(String format, Object... data)
    {
        log(Level.WARNING, format, data);
    }

    public static void info(String format, Object... data)
    {
        log(Level.INFO, format, data);
    }

    public static void fine(String format, Object... data)
    {
        log(Level.FINE, format, data);
    }

    public static void finer(String format, Object... data)
    {
        log(Level.FINER, format, data);
    }

    public static void finest(String format, Object... data)
    {
        log(Level.FINEST, format, data);
    }
    public static Logger getLogger()
    {
        return coreLog.getLogger();
    }
}

package cpw.mods.fml.common;

import java.util.logging.Level;
import java.util.logging.Logger;

public class FMLLog
{
    private static cpw.mods.fml.relauncher.FMLRelaunchLog coreLog = cpw.mods.fml.relauncher.FMLRelaunchLog.log;

    public static void log(Level level, String format, Object... data)
    {
        coreLog.log(level, String.format(format, data));
    }

    public static void log(Level level, Throwable ex, String format, Object... data)
    {
        coreLog.log(level, ex, String.format(format, data));
    }

    public static void severe(String format, Object... data)
    {
        log(Level.SEVERE, format, data);
    }

    public static void warning(String format, Object... data)
    {
        log(Level.WARNING, format, data);
    }

    public static void info(String format, Object... data)
    {
        log(Level.INFO, format, data);
    }

    public static void fine(String format, Object... data)
    {
        log(Level.FINE, format, data);
    }

    public static void finer(String format, Object... data)
    {
        log(Level.FINER, format, data);
    }

    public static void finest(String format, Object... data)
    {
        log(Level.FINEST, format, data);
    }
    public static Logger getLogger()
    {
        return coreLog.getLogger();
    }
}

Fix exception based logging to actually log the exception!


/* Classe: Carte
 * @author MARECAL Thomas
 * @author QUENTIN Thibaut
 * @author MARTIN Florian
 * Groupe I2
 * @version 1 du 04/06/2014
**/

package metier;

public class Carte {
	private static String[] COULEURS = { "ROUGE", "JAUNE", "VERT", "BLEU", "GRIS"};

	private String couleur = "NULL";
	private int valeur;

	public Carte ( String couleur, int valeur) {
		for ( String ch : COULEURS)
			if ( ch.equals(couleur))
				this.couleur = couleur;

		this.valeur = valeur;
	}
}

/* Classe: Carte
 * @author MARECAL Thomas
 * @author QUENTIN Thibaut
 * @author MARTIN Florian
 * Groupe I2
 * @version 1 du 04/06/2014
**/

package metier;

public class Carte {
	private final static String[] COULEURS = { "ROUGE", "JAUNE", "VERT", "BLEU", "GRIS"};

	private String couleur = "NULL";
	private int valeur;

	public Carte ( String couleur, int valeur) {
		for ( String ch : COULEURS)
			if ( ch.equals(couleur))
				this.couleur = couleur;

		this.valeur = valeur;
	}

	public String getCouleur () { return this.couleur; }
	public int    getValeur  () { return this.valeur;  }
}

Add getters for valeur and couleur


package tr.xip.wanikani.settings;

import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;

import tr.xip.wanikani.R;
import tr.xip.wanikani.managers.PrefManager;

/**
 * Created by xihsa_000 on 4/4/14.
 */
public class SettingsActivity extends PreferenceActivity {

    PrefManager prefMan;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);

        prefMan = new PrefManager(this);

        Preference mApiKey = findPreference(PrefManager.PREF_API_KEY);
        mApiKey.setSummary(prefMan.getApiKey());
    }

    @Override
    public void onBackPressed() {
        if (Build.VERSION.SDK_INT >= 16) {
            super.onNavigateUp();
        } else {
            super.onBackPressed();
        }
    }
}

package tr.xip.wanikani.settings;

import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;

import tr.xip.wanikani.R;
import tr.xip.wanikani.managers.PrefManager;

/**
 * Created by xihsa_000 on 4/4/14.
 */
public class SettingsActivity extends PreferenceActivity {

    PrefManager prefMan;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);

        prefMan = new PrefManager(this);

        Preference mApiKey = findPreference(PrefManager.PREF_API_KEY);

        String apiKey = prefMan.getApiKey();
        String maskedApiKey = "************************";

        for (int i = 25; i < apiKey.length(); i++) {
            maskedApiKey += apiKey.charAt(i);
        }

        mApiKey.setSummary(maskedApiKey);
    }

    @Override
    public void onBackPressed() {
        if (Build.VERSION.SDK_INT >= 16) {
            super.onNavigateUp();
        } else {
            super.onBackPressed();
        }
    }
}

Mask the API key shown in settings


package com.darwinsys.clientware;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * A JAX-RS client NOT using the JAX-RS Client API
 * In fact, not using anything except Core Java APIs.
 */
public class UrlJaxRsClient {

	static final String BASE_URL =
			"http://androidcookbook.com/seam/resource/rest/recipe";

	public static void main(String[] args) throws Exception {
		URL url = new URL(BASE_URL + "/4");
		final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
		connection.addRequestProperty("Accept", "application/json");
		InputStream is = connection.getInputStream();
		// Read "is" to get the response from a GET
		BufferedReader bi = new BufferedReader(new InputStreamReader(is));
		String line = null;
		while ((line = bi.readLine()) != null) {
			System.out.println(line);
		}
	}
}

package com.darwinsys.clientware;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * A JAX-RS client NOT using the JAX-RS Client API
 * In fact, not using anything except Core Java APIs.
 */
public class UrlJaxRsClient {

	static final String BASE_URL =
		"http://androidcookbook.com/seam/resource/rest/recipe";

	public static void main(String[] args) throws Exception {
		final int recipeId = 4;
		URL url = new URL(BASE_URL + "/" + recipeId);
		final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
		connection.addRequestProperty("Accept", "application/json");
		InputStream is = connection.getInputStream();
		// Read "is" to get the response from a GET
		BufferedReader bi = new BufferedReader(new InputStreamReader(is));
		String line = null;
		while ((line = bi.readLine()) != null) {
			System.out.println(line);
		}
	}
}

Clarify client code a bit


package org.callimachusproject.xslt;

import java.io.InputStream;
import java.io.Reader;

import javax.xml.transform.TransformerFactory;

public class XSLTransformerFactory {
	private static final XSLTransformerFactory instance = new XSLTransformerFactory();

	public static XSLTransformerFactory getInstance() {
		return instance;
	}

	private final TransformerFactory tfactory = new CachedTransformerFactory();

	XSLTransformerFactory() {
		super();
	}

	public XSLTransformer createTransformer(String systemId) {
		return new XSLTransformer(systemId, tfactory);
	}

	public XSLTransformer createTransformer(InputStream in, String systemId) {
		return new XSLTransformer(in, systemId, tfactory);
	}

	public XSLTransformer createTransformer(Reader r, String systemId) {
		return new XSLTransformer(r, systemId, tfactory);
	}

}

package org.callimachusproject.xslt;

import java.io.InputStream;
import java.io.Reader;

import javax.xml.transform.TransformerFactory;

public class XSLTransformerFactory {
	private static final XSLTransformerFactory instance = new XSLTransformerFactory();

	public static XSLTransformerFactory getInstance() {
		return instance;
	}

	private final TransformerFactory tfactory = new CachedTransformerFactory();

	XSLTransformerFactory() {
		super();
	}

	public XSLTransformer createTransformer() {
		return new XSLTransformer(null, tfactory);
	}

	public XSLTransformer createTransformer(String systemId) {
		return new XSLTransformer(systemId, tfactory);
	}

	public XSLTransformer createTransformer(InputStream in, String systemId) {
		return new XSLTransformer(in, systemId, tfactory);
	}

	public XSLTransformer createTransformer(Reader r, String systemId) {
		return new XSLTransformer(r, systemId, tfactory);
	}

}

Add identify transformer factory method


package inaka.com.tinytask;

public class TinyTask<T> {

    private static TinyTask instance = null;
    private GenericTask<T> genericTask;
    private Something<T> something;
    private DoThis<T> callback;

    private TinyTask(Something<T> something) {
        this.something = something;
    }

    private TinyTask(DoThis<T> callback) {
        this.callback = callback;
    }

    public static TinyTask perform(Something something) {
        if(instance == null) {
            instance = new TinyTask(something);
        } else {
            instance.something = something;
        }
        return instance;
    }

    public TinyTask whenDone(DoThis<T> callback) {
        if(instance == null) {
            instance = new TinyTask<>(callback);
        } else {
            instance.callback = callback;
        }
        return instance;
    }

    public Something<T> getSomething() {
        return something;
    }

    public DoThis<T> getCallback() {
        return callback;
    }

    public void go() {
        if(genericTask == null) {
            genericTask = new GenericTask<>(this);
            genericTask.execute();
        }
    }

    public void cancel() {
        if(genericTask != null) {
            genericTask.cancel(true);
        }
    }

    public boolean isCancelled() {
        return genericTask.isCancelled();
    }
}

package inaka.com.tinytask;

public class TinyTask<T> {

    private static TinyTask instance = null;
    private GenericTask<T> genericTask;
    private Something<T> something;
    private DoThis<T> callback;

    private TinyTask(Something<T> something) {
        this.something = something;
    }

    private TinyTask(DoThis<T> callback) {
        this.callback = callback;
    }

    public static TinyTask perform(Something something) {
        if(instance == null) {
            instance = new TinyTask(something);
        } else {
            instance.something = something;
        }
        return instance;
    }

    public TinyTask whenDone(DoThis<T> callback) {
        if(instance == null) {
            instance = new TinyTask<>(callback);
        } else {
            instance.callback = callback;
        }
        return instance;
    }

    public Something<T> getSomething() {
        return something;
    }

    public DoThis<T> getCallback() {
        return callback;
    }

    public void go() {
        if(genericTask == null) {
            genericTask = new GenericTask<>(this);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                genericTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            } else {
                genericTask.execute();
            }
        }
    }

    public void cancel() {
        if(genericTask != null) {
            genericTask.cancel(true);
        }
    }

    public boolean isCancelled() {
        return genericTask.isCancelled();
    }
}

Make AsyncTasks parallel on API 11+


package com.jentfoo.classloading;

import org.junit.Test;
import org.threadly.util.Clock;

public class LoadClassesTest {
  @Test
  public void loadClasses() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    long start = Clock.accurateForwardProgressingMillis();
    for (int i = 0; i < GenerateClasses.CLASS_COUNT; i++) {
      @SuppressWarnings("unchecked")
      Class<? extends AbstractGenerated> c =
          (Class<? extends AbstractGenerated>) Class.forName(this.getClass().getPackage().getName() +
                                                               ".generated." +
                                                               GenerateClasses.CLASS_PREFIX + i);
      @SuppressWarnings("unused")
      AbstractGenerated genClass = c.newInstance();
      genClass.foo();
    }
    System.out.println("---> run time: " + (Clock.accurateForwardProgressingMillis() - start));
  }
}

package com.jentfoo.classloading;

import org.junit.Test;
import org.threadly.util.Clock;

public class LoadClassesTest {
  @Test
  public void loadClasses() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    long start = Clock.accurateForwardProgressingMillis();
    for (int i = 0; i < GenerateClasses.CLASS_COUNT; i++) {
      ClassLoader.getSystemClassLoader().loadClass(this.getClass().getPackage().getName() +
                                                     ".generated." + GenerateClasses.CLASS_PREFIX + i);
    }
    System.out.println("---> run time: " + (Clock.accurateForwardProgressingMillis() - start));
  }
}

Use ClassLoader rather than Class.forName


package foodtruck.server;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.inject.Inject;
import com.google.inject.Singleton;

import foodtruck.twitter.TwitterService;

/**
 * @author aviolette@gmail.com
 * @since 10/11/11
 */
@Singleton
public class TweetCacheUpdateServlet  extends HttpServlet implements Runnable {
  private final TwitterService service;

  @Inject
  public TweetCacheUpdateServlet(TwitterService service) {
    this.service = service;
  }

  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    run();
  }

  @Override
  public void run() {
    service.updateTwitterCache();
    service.updateLocationsOfTwitterTrucks();
  }
}

package foodtruck.server;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.inject.Inject;
import com.google.inject.Singleton;

import foodtruck.twitter.TwitterService;

/**
 * @author aviolette@gmail.com
 * @since 10/11/11
 */
@Singleton
public class TweetCacheUpdateServlet  extends HttpServlet implements Runnable {
  private static final Logger log = Logger.getLogger(TweetCacheUpdateServlet.class.getName());
  private final TwitterService service;

  @Inject
  public TweetCacheUpdateServlet(TwitterService service) {
    this.service = service;
  }

  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    run();
  }

  @Override
  public void run() {
    try {
      service.updateTwitterCache();
    } catch (Exception e) {
      log.log(Level.WARNING, "Error updating twitter cache", e);
    }
    service.updateLocationsOfTwitterTrucks();
  }
}

Fix it so we update the location of the twitter cached trucks even if there is a failure updating the cache.


package seedu.address.logic.commands;

public class UndoCommand extends Command {

    public static final String COMMAND_WORD = "undo";
    public static final String MESSAGE_USAGE = COMMAND_WORD;
    public static final String MESSAGE_SUCCESS = "Successfully undo previous change";
    public static final String MESSAGE_NO_CHANGE = "No change to be undone";

    /**
     * Default empty constructor.
     */
    public UndoCommand() {
    }

    public CommandResult execute() {
        if (!model.getFlag().equals("undo copy")) {
            return new CommandResult(MESSAGE_NO_CHANGE);
        } else {
            model.resetData(model.getCopy());
            model.updateFlag("empty copy");
            return new CommandResult(MESSAGE_SUCCESS);
        }
    }
}

package seedu.address.logic.commands;

import seedu.address.model.TaskManager;

public class UndoCommand extends Command {

    public static final String COMMAND_WORD = "undo";
    public static final String MESSAGE_USAGE = COMMAND_WORD;
    public static final String MESSAGE_SUCCESS = "Successfully undo previous change";
    public static final String MESSAGE_NO_CHANGE = "No change to be undone";

    /**
     * Default empty constructor.
     */
    public UndoCommand() {
    }

    public CommandResult execute() {
        if (!model.getFlag().equals("undo copy")) {
            return new CommandResult(MESSAGE_NO_CHANGE);
        } else {
            TaskManager temp = new TaskManager(model.getTaskManager());
            model.resetData(model.getCopy());
            model.updateFlag("redo copy");
            model.updateCopy(temp);
            return new CommandResult(MESSAGE_SUCCESS);
        }
    }
}

Modify undo command to support redo command


package com.rnscm;

import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Callback;

import java.util.Map;
import java.util.HashMap;
import java.lang.reflect.Field;

public class SecretConfigManager extends ReactContextBaseJavaModule {

    public Class config;

    public SecretConfigManager(ReactApplicationContext reactContext, Class _config) {
        super(reactContext);
        config = _config;
    }

    @Override
    public String getName() {
        return "SecretConfigManager";
    }

    private Map<String,String> configToMap() {
        Field[] declaredFields = config.getDeclaredFields();
        Map<String, String> configMap = new HashMap<String, String>();
        for (Field field : declaredFields) {
            if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
                String key = field.getName();
                String val = (String)field.get(null);
                configMap.put(key, val);
            }
        }
        return configMap;
    }

    @ReactMethod
    public void getConfig(String name, Callback callback) {
        callback.invoke(configToMap());
    }

}

package com.rnscm;

import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Callback;

import java.util.Map;
import java.util.HashMap;
import java.lang.reflect.Field;

public class SecretConfigManager extends ReactContextBaseJavaModule {

    public Class config;

    public SecretConfigManager(ReactApplicationContext reactContext, Class _config) {
        super(reactContext);
        config = _config;
    }

    @Override
    public String getName() {
        return "SecretConfigManager";
    }

    private Map<String,String> configToMap() throws IllegalAccessException {
        Field[] declaredFields = config.getDeclaredFields();
        Map<String, String> configMap = new HashMap<String, String>();
        for (Field field : declaredFields) {
            if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
                String key = field.getName();
                String val = (String)field.get(null);
                configMap.put(key, val);
            }
        }
        return configMap;
    }

    @ReactMethod
    public void getConfig(String name, Callback callback) {
        try {
            callback.invoke(configToMap());
        } catch (IllegalAccessException err) {
            callback.invoke(err);
        }
    }

}

Fix all errors in java code


package org.openstack.client.internals;

import org.codehaus.jackson.Version;
import org.codehaus.jackson.map.module.SimpleModule;
import org.openstack.model.compute.Addresses;
import org.openstack.model.compute.SecurityGroup;
import org.openstack.model.compute.SecurityGroupList;
import org.openstack.model.compute.Server;
import org.openstack.model.identity.Access;

public class OpenstackSerializationModule extends SimpleModule {

	public OpenstackSerializationModule() {
		super(OpenstackSerializationModule.class.getName(), new Version(1, 0, 0, null));
		addSerializer(Addresses.class, new AddressesSerializer());
		addDeserializer(Addresses.class, new AddressesDeserializer());

		// Compute
		installSmartDeserializer(SecurityGroup.class);
		installSmartDeserializer(SecurityGroupList.class);
		installSmartDeserializer(Server.class);

		// Keystone (Redux)
		installSmartDeserializer(Access.class);
	}

	private <T> void installSmartDeserializer(Class<T> c) {
		addDeserializer(c, new SmartDeserializer<T>(c));
	}
}

package org.openstack.client.internals;

import org.codehaus.jackson.Version;
import org.codehaus.jackson.map.module.SimpleModule;
import org.openstack.model.compute.Addresses;
import org.openstack.model.compute.BadRequest;
import org.openstack.model.compute.SecurityGroup;
import org.openstack.model.compute.SecurityGroupList;
import org.openstack.model.compute.Server;
import org.openstack.model.identity.Access;

public class OpenstackSerializationModule extends SimpleModule {

	public OpenstackSerializationModule() {
		super(OpenstackSerializationModule.class.getName(), new Version(1, 0, 0, null));
		addSerializer(Addresses.class, new AddressesSerializer());
		addDeserializer(Addresses.class, new AddressesDeserializer());

		// Compute
		installSmartDeserializer(SecurityGroup.class);
		installSmartDeserializer(SecurityGroupList.class);
		installSmartDeserializer(Server.class);
		installSmartDeserializer(BadRequest.class);

		// Keystone (Redux)
		installSmartDeserializer(Access.class);
	}

	private <T> void installSmartDeserializer(Class<T> c) {
		addDeserializer(c, new SmartDeserializer<T>(c));
	}
}

Use the smart JSON serializer for BadRequest


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package npanday.resolver.filter;

import npanday.ArtifactType;
import npanday.ArtifactTypeHelper;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;

/**
 * @author Lars Corneliussen, Faktum Software
 */
public class DotnetSymbolsArtifactFilter
    implements ArtifactFilter
{
    public boolean include( Artifact artifact )
    {
        return artifact.getType() == ArtifactType.DOTNET_SYMBOLS.getPackagingType();
    }

    @Override
    public String toString() {
        return "DotnetSymbols";
    }
}

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package npanday.resolver.filter;

import npanday.ArtifactType;
import npanday.ArtifactTypeHelper;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;

/**
 * @author Lars Corneliussen, Faktum Software
 */
public class DotnetSymbolsArtifactFilter
    implements ArtifactFilter
{
    public boolean include( Artifact artifact )
    {
        return artifact.getType().equals(ArtifactType.DOTNET_SYMBOLS.getPackagingType());
    }

    @Override
    public String toString() {
        return "DotnetSymbols";
    }
}

Add support to automatically attach PDB-symbols and Code-Documentation (comment.xml)


package org.dita.dost;

import org.junit.Test;

import java.io.File;
import java.nio.file.Paths;

import static org.dita.dost.AbstractIntegrationTest.Transtype.*;

public class EndToEndTest extends AbstractIntegrationTest {

    @Test
    public void xhtml() throws Throwable {
        builder().name("e2e")
                .transtype(XHTML)
                .input(Paths.get("root.ditamap"))
                .run();
    }

    @Test
    public void html5() throws Throwable {
        builder().name("e2e")
                .transtype(HTML5)
                .input(Paths.get("root.ditamap"))
                .run();
    }

    @Test
    public void pdf() throws Throwable {
        builder().name("e2e")
                .transtype(PDF)
                .input(Paths.get("root.ditamap"))
                .put("args.fo.userconfig", new File(resourceDir, "e2e" + File.separator + "fop.xconf").getAbsolutePath())
                .warnCount(10)
                .run();
    }

    @Test
    public void eclipsehelp() throws Throwable {
        builder().name("e2e")
                .transtype(ECLIPSEHELP)
                .input(Paths.get("root.ditamap"))
                .run();
    }

    @Ignore
    @Test
    public void htmlhelp() throws Throwable {
        builder().name("e2e")
                .transtype(HTMLHELP)
                .input(Paths.get("root.ditamap"))
                .run();
    }

}

package org.dita.dost;

import org.junit.Ignore;
import org.junit.Test;

import java.io.File;
import java.nio.file.Paths;

import static org.dita.dost.AbstractIntegrationTest.Transtype.*;

public class EndToEndTest extends AbstractIntegrationTest {

    @Test
    public void xhtml() throws Throwable {
        builder().name("e2e")
                .transtype(XHTML)
                .input(Paths.get("root.ditamap"))
                .run();
    }

    @Test
    public void html5() throws Throwable {
        builder().name("e2e")
                .transtype(HTML5)
                .input(Paths.get("root.ditamap"))
                .run();
    }

    @Test
    public void pdf() throws Throwable {
        builder().name("e2e")
                .transtype(PDF)
                .input(Paths.get("root.ditamap"))
                .put("args.fo.userconfig", new File(resourceDir, "e2e" + File.separator + "fop.xconf").getAbsolutePath())
                .warnCount(10)
                .run();
    }

    @Test
    public void eclipsehelp() throws Throwable {
        builder().name("e2e")
                .transtype(ECLIPSEHELP)
                .input(Paths.get("root.ditamap"))
                .run();
    }

    @Ignore
    @Test
    public void htmlhelp() throws Throwable {
        builder().name("e2e")
                .transtype(HTMLHELP)
                .input(Paths.get("root.ditamap"))
                .run();
    }

}

Add import of Ignore for ignored HTMLHelp test


package vtk.rendering;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;

/**
 * This class implement vtkEventInterceptor with no event interception at all.
 *
 * @see {@link MouseMotionListener} {@link MouseListener} {@link MouseWheelListener}
 *      {@link KeyListener}
 *
 * @author    Sebastien Jourdain - sebastien.jourdain@kitware.com, Kitware Inc 2013
 */

public class vtkAbstractEventInterceptor implements vtkEventInterceptor {

  @Override
  public boolean keyPressed(KeyEvent e) {
    return false;
  }

  @Override
  public boolean keyReleased(KeyEvent e) {
    return false;
  }

  @Override
  public boolean keyTyped(KeyEvent e) {
    return false;
  }

  @Override
  public boolean mouseDragged(MouseEvent e) {
    return false;
  }

  @Override
  public boolean mouseMoved(MouseEvent e) {
    return false;
  }

  @Override
  public boolean mouseClicked(MouseEvent e) {
    return false;
  }

  @Override
  public boolean mouseEntered(MouseEvent e) {
    return false;
  }

  @Override
  public boolean mouseExited(MouseEvent e) {
    return false;
  }

  @Override
  public boolean mousePressed(MouseEvent e) {
    return false;
  }

  @Override
  public boolean mouseReleased(MouseEvent e) {
    return false;
  }

  @Override
  public boolean mouseWheelMoved(MouseWheelEvent e) {
    return false;
  }
}

package vtk.rendering;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;

/**
 * This class implement vtkEventInterceptor with no event interception at all.
 *
 * @see {@link MouseMotionListener} {@link MouseListener} {@link MouseWheelListener}
 *      {@link KeyListener}
 *
 * @author    Sebastien Jourdain - sebastien.jourdain@kitware.com, Kitware Inc 2013
 */

public class vtkAbstractEventInterceptor implements vtkEventInterceptor {

  public boolean keyPressed(KeyEvent e) {
    return false;
  }

  public boolean keyReleased(KeyEvent e) {
    return false;
  }

  public boolean keyTyped(KeyEvent e) {
    return false;
  }

  public boolean mouseDragged(MouseEvent e) {
    return false;
  }

  public boolean mouseMoved(MouseEvent e) {
    return false;
  }

  public boolean mouseClicked(MouseEvent e) {
    return false;
  }

  public boolean mouseEntered(MouseEvent e) {
    return false;
  }

  public boolean mouseExited(MouseEvent e) {
    return false;
  }

  public boolean mousePressed(MouseEvent e) {
    return false;
  }

  public boolean mouseReleased(MouseEvent e) {
    return false;
  }

  public boolean mouseWheelMoved(MouseWheelEvent e) {
    return false;
  }
}

Remove @Override annotation to prevent compilation issue on old Java compiler


/*
 * Copyright (C) 2013 Square, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package retrofit.http;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/** Make a PATCH request to a REST path relative to base URL. */
@Target(METHOD)
@Retention(RUNTIME)
@RestMethod(value = "PATCH", hasBody = true)
public @interface PATCH {
  String value();
}

/*
 * Copyright (C) 2013 Square, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package retrofit.http;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/** Make a PATCH request to a REST path relative to base URL. */
@Documented
@Target(METHOD)
@Retention(RUNTIME)
@RestMethod(value = "PATCH", hasBody = true)
public @interface PATCH {
  String value();
}

Add @Documented annotation for the new REST annotation.


package common;

public enum RequestType {
	MOVE,
	ATTACK,
	HARVEST,
	LOG_IN,
	LOG_OUT,
	REGISTER,
	CRAFT,
	TILE;

	static final long serialVersionUID = 12142322;
}

package common;

public enum RequestType {
	MOVE,
	ATTACK,
	HARVEST,
	LOG_IN,
	LOG_OUT,
	REGISTER,
	CRAFT,
	TILE,
	UPDATE_TILE,
	CONFIRM;

	static final long serialVersionUID = 12142322;
}

Add types like Update_tile , confirm


package com.Acrobot.ChestShop.Plugins;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;

/**
 * @author Brokkonaut
 */
public class WorldGuardFlags {
    public static final StateFlag ENABLE_SHOP;

    static {
        StateFlag enableShop;
        try {
            enableShop = Flags.register(new StateFlag("allow-shop", false));
        } catch (FlagConflictException | IllegalStateException e) {
            enableShop = (StateFlag) Flags.get("allow-shop");
        }
        ENABLE_SHOP = enableShop;
    }
}

package com.Acrobot.ChestShop.Plugins;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;

/**
 * @author Brokkonaut
 */
public class WorldGuardFlags {
    public static final StateFlag ENABLE_SHOP;

    static {
        StateFlag enableShop;
        try {
            enableShop = new StateFlag("allow-shop", false);
            WorldGuard.getInstance().getFlagRegistry().register(enableShop);
        } catch (FlagConflictException | IllegalStateException e) {
            enableShop = (StateFlag) Flags.get("allow-shop");
        }
        ENABLE_SHOP = enableShop;
    }
}

Use registry to register WorldGuard flags


package se.kits.gakusei.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import se.kits.gakusei.user.model.User;
import se.kits.gakusei.user.repository.UserRepository;

@Service("userDetailsService")
public class UserDetailsServiceImpl implements UserDetailsService {

    private final UserRepository repository;

    @Autowired
    public UserDetailsServiceImpl(UserRepository repository) {
        this.repository = repository;
    }

    @Override
    public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException {
        User user = this.repository.findByUsername(name);
        return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(),
                AuthorityUtils.createAuthorityList(user.getRole()));
    }

}

package se.kits.gakusei.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import se.kits.gakusei.user.model.User;
import se.kits.gakusei.user.repository.UserRepository;

@Service("userDetailsService")
public class UserDetailsServiceImpl implements UserDetailsService {

    private final UserRepository repository;

    @Autowired
    public UserDetailsServiceImpl(UserRepository repository) {
        this.repository = repository;
    }

    @Override
    public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException {
        User user = this.repository.findByUsername(name);
        if (user == null) throw new UsernameNotFoundException("User not found: " + name);
        return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(),
                AuthorityUtils.createAuthorityList(user.getRole()));
    }

}

Fix exception when trying to login with non-existing user


 package primes.bramble;

import java.io.Serializable;
import java.util.ArrayList;

import primes.PrimeGenerator;
import bramble.node.slave.ISlaveNodeRunner;
import bramble.node.slave.SlaveNode;

/**
 * This is an example of how a SlaveNode can be run.
 *
 * This class is responsible for passing a job from the
 * API to a class that will accept a job.
 *
 * @author Tom
 *
 */
public class SlaveNodeRunner implements ISlaveNodeRunner{

	private static String IPADDR;

	@SuppressWarnings("unused")
	public static void main(String[] args){

		if(args.length != 1){
			System.out.println("Didn't find an IP on the command line, exiting");
			System.exit(1);
		} else {
			IPADDR = args[0];
			System.out.println("Slave node initiated, my IP is " + IPADDR);
		}

		new SlaveNodeRunner();
	}

	public SlaveNodeRunner(){
		(new SlaveNode<>(IPADDR, this)).listenForever();
	}

	@Override
	public void runJob(int jobID, ArrayList<Serializable> initializationData) {
		//System.out.print("[" + jobID + "] ");
		PrimeGenerator primeGenerator = new PrimeGenerator(IPADDR, jobID, initializationData);
		primeGenerator.run();
	}

}

 package primes.bramble;

import java.io.Serializable;
import java.util.ArrayList;

import primes.PrimeGenerator;
import bramble.node.slave.ISlaveNodeRunner;
import bramble.node.slave.SlaveNode;

/**
 * This is an example of how a SlaveNode can be run.
 *
 * This class is responsible for passing a job from the
 * API to a class that will accept a job.
 *
 * @author Tom
 *
 */
public class SlaveNodeRunner implements ISlaveNodeRunner{

	private final String ipAddress;

	public static void main(String[] args){

		if(args.length != 1){
			System.out.println("Didn't find an IP on the command line, exiting");
			return;
		}

		String ipAddress = args[0];
		System.out.println("Slave node initiated, my IP is " + ipAddress);
		(new SlaveNodeRunner(ipAddress)).initialize();
	}

	public SlaveNodeRunner(String ipAddress){
		this.ipAddress = ipAddress;
	}

	public void initialize(){
		(new SlaveNode<>(this.ipAddress, this)).listenForever();
	}

	@Override
	public void runJob(int jobID, ArrayList<Serializable> initializationData) {
		//System.out.print("[" + jobID + "] ");
		PrimeGenerator primeGenerator = new PrimeGenerator(this.ipAddress, jobID, initializationData);
		primeGenerator.run();
	}

}

Refactor static variables out of slave node runner


package com.kogimobile.android.baselibrary.app.busevents;

/**
 * @author Julian Cardona on 7/11/14.
 */
public class EventProgressDialog {

    public static Builder getBuilder() {
        return new Builder();
    }

    private boolean show = false;
    private String progressDialogMessage = "";

    private EventProgressDialog(Builder builder){
        this.show = builder.show;
        this.progressDialogMessage = builder.message;
    }

    public boolean isShown() {
        return show;
    }

    public String getProgressDialogMessage() {
        return progressDialogMessage;
    }

    public static class Builder {
        private boolean show;
        private String message;

        public Builder withShow(boolean show) {
            this.show = show;
            return this;
        }

        public Builder withMessage(String message) {
            this.message = message;
            return this;
        }

        public EventProgressDialog build() {
            return new EventProgressDialog(this);
        }
    }

    /**
     *
     * @deprecated Please use builder pattern
     */
    @Deprecated
    private EventProgressDialog(boolean show, String message){
        setShow(show);
        setProgressDialogMessage(message);
    }

    /**
     *
     * @deprecated Please use builder pattern
     */
    @Deprecated
    public EventProgressDialog setShow(boolean show) {
        this.show = show;
        return this;
    }

    /**
     *
     * @deprecated Please use builder pattern
     */
    @Deprecated
    public EventProgressDialog setProgressDialogMessage(String progressDialogMessage) {
        this.progressDialogMessage = progressDialogMessage;
        return this;
    }

}

package com.kogimobile.android.baselibrary.app.busevents;

/**
 * @author Julian Cardona on 7/11/14.
 */
public class EventProgressDialog {

    public static Builder getBuilder() {
        return new Builder();
    }

    private boolean show = true;
    private String progressDialogMessage = "";

    private EventProgressDialog(Builder builder){
        this.show = builder.show;
        this.progressDialogMessage = builder.message;
    }

    public boolean isShown() {
        return show;
    }

    public String getProgressDialogMessage() {
        return progressDialogMessage;
    }

    public static class Builder {
        private boolean show;
        private String message;

        public Builder withShow(boolean show) {
            this.show = show;
            return this;
        }

        public Builder withMessage(String message) {
            this.message = message;
            return this;
        }

        public Builder dismiss(){
            this.show = false;
            return this;
        }

        public EventProgressDialog build() {
            return new EventProgressDialog(this);
        }
    }

    /**
     *
     * @deprecated Please use builder pattern
     */
    @Deprecated
    private EventProgressDialog(boolean show, String message){
        setShow(show);
        setProgressDialogMessage(message);
    }

    /**
     *
     * @deprecated Please use builder pattern
     */
    @Deprecated
    public EventProgressDialog setShow(boolean show) {
        this.show = show;
        return this;
    }

    /**
     *
     * @deprecated Please use builder pattern
     */
    @Deprecated
    public EventProgressDialog setProgressDialogMessage(String progressDialogMessage) {
        this.progressDialogMessage = progressDialogMessage;
        return this;
    }

}

Add dismiss method for progress dialog on builder


package edu.umn.csci5801.model;

import java.util.List;

/**
 * Created by Justin on 12/2/2014.
 */
public class GradReqCheck {
    private String reqName;
    private boolean result;
    private Requirement details;

    public GradReqCheck() {}
    public GradReqCheck(String n) {
        reqName = n;
    }

    public void setReqName(String n) { reqName = n; }
    public void setResult(boolean ic) { result = ic; }
    public void setDetails(Requirement r) { details = r; }

    public String getReqName() { return reqName; }
    public boolean getResult() { return result; }
    public Requirement getDetails() { return details; }

    public void testReq(Requirement requirement, List<CourseTaken> courseTakenList, List<CompletedMilestone> completedMilestoneList) {
        //DETERMINE WHETHER REQUIREMENT PASSED IN IS MET IN COURSETAKENLIST AND COMPLETEDMILESTONES
        //TODO: Logic for checking any given requirement
        switch (requirement.getName()) {
            //TODO: Fill in all the different case statements (one for each possible requirement name
            case "BREADTH_REQUIREMENT_MS":
        }
    }
}

package edu.umn.csci5801.model;

import java.util.List;

/**
 * Created by Justin on 12/2/2014.
 */
public class GradReqCheck {
    private Reqs reqName;
    private boolean result;
    private Requirement details;

    public GradReqCheck() {}
    public GradReqCheck(Reqs n) {
        reqName = n;
    }

    public void setReqName(Reqs n) { reqName = n; }
    public void setResult(boolean ic) { result = ic; }
    public void setDetails(Requirement r) { details = r; }

    public Reqs getReqName() { return reqName; }
    public boolean getResult() { return result; }
    public Requirement getDetails() { return details; }

    public void testReq(Requirement requirement, List<CourseTaken> courseTakenList, List<CompletedMilestone> completedMilestoneList) {
        //DETERMINE WHETHER REQUIREMENT PASSED IN IS MET IN COURSETAKENLIST AND COMPLETEDMILESTONES
        //TODO: Logic for checking any given requirement
        switch (requirement.getName()) {
            //TODO: Fill in all the different case statements (one for each possible requirement name
            case BREADTH_REQUIREMENT_MS:
        }
    }
}

Update Requirements.name to Reqs enum


/******************************************************************************
 * Copyright (c) 2006, 2010 VMware Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 * The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
 * is available at http://www.opensource.org/licenses/apache2.0.php.
 * You may elect to redistribute this code under either of these licenses.
 *
 * Contributors:
 *   VMware Inc.
 *****************************************************************************/

package org.eclipse.gemini.blueprint.internal.service.collection.threading;

import edu.umd.cs.mtc.MultithreadedTest;
import edu.umd.cs.mtc.TestFramework;

/**
 * @author Costin Leau
 *
 */
public abstract class BaseThreadingTest extends MultithreadedTest {

	static int RUN_TIMES = 3;

	public void runTest() throws Throwable {
		TestFramework.runManyTimes(this, RUN_TIMES);
	}

	public void testRun() throws Throwable {
		// do nothing - just to comply with the test suite
	}

}

/******************************************************************************
 * Copyright (c) 2006, 2010 VMware Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 * The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
 * is available at http://www.opensource.org/licenses/apache2.0.php.
 * You may elect to redistribute this code under either of these licenses.
 *
 * Contributors:
 *   VMware Inc.
 *****************************************************************************/

package org.eclipse.gemini.blueprint.internal.service.collection.threading;

import edu.umd.cs.mtc.MultithreadedTest;
import edu.umd.cs.mtc.TestFramework;
import org.junit.Test;

/**
 * @author Costin Leau
 *
 */
public abstract class BaseThreadingTest extends MultithreadedTest {
	static int RUN_TIMES = 3;

    @Test
	public void runTest() throws Throwable {
		TestFramework.runManyTimes(this, RUN_TIMES);
	}
}

Support for junit 4.7+ maven test runner, previously this test would not have been run and without this change it receives a No runnable methods found error.


import java.io.*;

public class OpenStream {
	public static void main(String[] argv) throws Exception {
		FileInputStream in = null;

		try {
			in = new FileInputStream(argv[0]);
		} finally {
			// Not guaranteed to be closed here!
			if (Boolean.getBoolean("inscrutable"))
				in.close();
		}

		FileInputStream in2 = null;
		try {
			in2 = new FileInputStream(argv[1]);
		} finally {
			// This one will be closed
			if (in2 != null)
				in2.close();
		}

		// oops!  exiting the method without closing the stream
	}

	public void byteArrayStreamDoNotReport() {
		ByteArrayOutputStream b = new ByteArrayOutputStream();
		PrintStream out = new PrintStream(b);

		out.println("Hello, world!");
	}

	public void systemInDoNotReport() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		System.out.println(reader.readLine());
	}

	public void socketDoNotReport(java.net.Socket socket) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		System.out.println(reader.readLine());
	}
}

import java.io.*;

public class OpenStream {
	public static void main(String[] argv) throws Exception {
		FileInputStream in = null;

		try {
			in = new FileInputStream(argv[0]);
		} finally {
			// Not guaranteed to be closed here!
			if (Boolean.getBoolean("inscrutable"))
				in.close();
		}

		FileInputStream in2 = null;
		try {
			in2 = new FileInputStream(argv[1]);
		} finally {
			// This one will be closed
			if (in2 != null)
				in2.close();
		}

		// oops!  exiting the method without closing the stream
	}

	public void byteArrayStreamDoNotReport() {
		ByteArrayOutputStream b = new ByteArrayOutputStream();
		PrintStream out = new PrintStream(b);

		out.println("Hello, world!");
	}

	public void systemInDoNotReport() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		System.out.println(reader.readLine());
	}

	public void socketDoNotReport(java.net.Socket socket) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		System.out.println(reader.readLine());
	}

	public void paramStreamDoNotReport(java.io.OutputStream os) throws IOException {
		PrintStream ps = new PrintStream(os);
		ps.println("Hello");
	}
}

// vim:ts=4

Add test case for wrapping a stream passed as a param


package com.github.ferstl.depgraph;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.shared.dependency.graph.DependencyNode;

import com.github.ferstl.depgraph.dot.NodeRenderer;
import com.google.common.base.Joiner;

enum NodeRenderers implements NodeRenderer {
  ARTIFACT_ID_LABEL {
    @Override
    public String render(DependencyNode node) {
      Artifact artifact = node.getArtifact();
      return toScopedString(artifact.getArtifactId(), artifact.getScope());
    }
  },

  GROUP_ID_LABEL {

    @Override
    public String render(DependencyNode node) {
      Artifact artifact = node.getArtifact();
      return toScopedString(artifact.getGroupId(), artifact.getScope());
    }

  },

  SCOPED_GROUP_ID {
    @Override
    public String render(DependencyNode node) {
      Artifact artifact = node.getArtifact();
      return COLON_JOINER.join(artifact.getGroupId(), artifact.getScope());
    }
  },

  VERSIONLESS_ID {

    @Override
    public String render(DependencyNode node) {
      Artifact artifact = node.getArtifact();

      return COLON_JOINER.join(
          artifact.getGroupId(),
          artifact.getArtifactId(),
          artifact.getType(),
          artifact.getClassifier(),
          artifact.getScope());
    }

  };

  private static final Joiner COLON_JOINER = Joiner.on(":").useForNull("");

  private static String toScopedString(String string, String scope) {
    if (!"compile".equals(scope)) {
      return string + "\\n(" + scope + ")";
    }

    return string;
  }

}

package com.github.ferstl.depgraph;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.shared.dependency.graph.DependencyNode;

import com.github.ferstl.depgraph.dot.NodeRenderer;
import com.google.common.base.Joiner;

enum NodeRenderers implements NodeRenderer {
  ARTIFACT_ID_LABEL {
    @Override
    public String render(DependencyNode node) {
      Artifact artifact = node.getArtifact();
      return toScopedString(artifact.getArtifactId(), artifact.getScope());
    }
  },

  GROUP_ID_LABEL {

    @Override
    public String render(DependencyNode node) {
      Artifact artifact = node.getArtifact();
      return toScopedString(artifact.getGroupId(), artifact.getScope());
    }

  },

  SCOPED_GROUP_ID {
    @Override
    public String render(DependencyNode node) {
      Artifact artifact = node.getArtifact();
      return COLON_JOINER.join(artifact.getGroupId(), artifact.getScope());
    }
  },

  VERSIONLESS_ID {

    @Override
    public String render(DependencyNode node) {
      Artifact artifact = node.getArtifact();

      return COLON_JOINER.join(
          artifact.getGroupId(),
          artifact.getArtifactId(),
          artifact.getType(),
          artifact.getClassifier(),
          artifact.getScope());
    }

  };

  private static final Joiner COLON_JOINER = Joiner.on(":").useForNull("");

  private static String toScopedString(String string, String scope) {
    if (scope != null && !"compile".equals(scope)) {
      return string + "\\n(" + scope + ")";
    }

    return string;
  }

}

Add null check for scope


package com.google.sps.data;

/** Listing object with the specified attributes returned from the places API **/
public class Listing {
    private String name;
    private MapLocation mapLocation;
    private double rating;
    private String image;
    private String url;
    private String businessType;

  /**
  * Creates a new Listing
  * @param name Name of business
  * @param mapLocation Location of business (lat/long coordinate)
  * @param rating Numerical rating of business (1-5)
  * @param image Image
  * @param url Url to business' site
  * @param businessType specifies business type from Places API (establishment, food, etc.)
  * @return Listing object
  **/

  public Listing(String name, MapLocation mapLocation, double rating, String image, String url) {
    this.name = name;
    this.mapLocation = mapLocation;
    this.rating = rating;
    this.image = image;
    this.url = url;
    this.businessType = businessType;
  }

  public String getName() {
    return name;
  }

  public MapLocation getMapLocation() {
    return mapLocation;
  }

  public double getRating() {
    return rating;
  }

  public String getImage() {
    return image;
  }

  public String getUrl() {
    return url;
  }

  public String getBusinessType() {
    return businessType;
  }
}

package com.google.sps.data;
import com.google.maps.model.Photo;

/** Listing object with the specified attributes returned from the places API **/
public class Listing {
    private String name;
    private MapLocation mapLocation;
    private double rating;
    private Photo photos[];
    private String businessTypes[];

  /**
  * Creates a new Listing
  * @param name Name of business
  * @param mapLocation Location of business (lat/long coordinate)
  * @param rating Numerical rating of business (1-5)
  * @param photos Array of Google Photo objects
  * @param businessType specifies business type from Places API (establishment, food, etc.)
  * @return Listing object
  **/

  public Listing(String name, MapLocation mapLocation, double rating, Photo photos[], String businessTypes[]) {
    this.name = name;
    this.mapLocation = mapLocation;
    this.rating = rating;
    this.photos = photos;
    this.businessTypes = businessTypes;
  }

  public String getName() {
    return name;
  }

  public MapLocation getMapLocation() {
    return mapLocation;
  }

  public double getRating() {
    return rating;
  }

  public Photo[] getPhotos() {
    return photos;
  }

  public String[] getBusinessTypes() {
    return businessTypes;
  }
}

Change parameters for places api output


/*
 * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.yangtools.yang.data.util;

import static com.google.common.base.Preconditions.checkArgument;

import com.google.common.annotations.Beta;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Module;

@Beta
public abstract class AbstractModuleStringIdentityrefCodec extends AbstractStringIdentityrefCodec {
    /**
     * Resolve a string prefix into the corresponding module.
     *
     * @param prefix Prefix
     * @return module mapped to prefix, or null if the module cannot be resolved
     */
    protected abstract Module moduleForPrefix(@Nonnull String prefix);

    @Override
    protected final QName createQName(@Nonnull final String prefix, @Nonnull final String localName) {
        final Module module = moduleForPrefix(prefix);
        checkArgument(module != null, "Failed to lookup prefix %s", prefix);
        return QName.create(module.getQNameModule(), localName);
    }
}

/*
 * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.yangtools.yang.data.util;

import static com.google.common.base.Preconditions.checkArgument;

import com.google.common.annotations.Beta;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;

@Beta
public abstract class AbstractModuleStringIdentityrefCodec extends AbstractStringIdentityrefCodec {
    /**
     * Resolve a string prefix into the corresponding module.
     *
     * @param prefix Prefix
     * @return module mapped to prefix, or null if the module cannot be resolved
     */
    protected abstract Module moduleForPrefix(@Nonnull String prefix);

    @Override
    protected final QName createQName(@Nonnull final String prefix, @Nonnull final String localName) {
        final Module module = moduleForPrefix(prefix);
        checkArgument(module != null, "Failed to lookup prefix %s", prefix);

        final QName qname = QName.create(module.getQNameModule(), localName);
        for (IdentitySchemaNode identity : module.getIdentities()) {
            if (qname.equals(identity.getQName())) {
                return identity.getQName();
            }
        }

        throw new IllegalArgumentException("Failed to find identity matching " + qname);
    }
}

Validate parsed QName to identity


package com.github.mobile.android.repo;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.github.mobile.android.R.id;
import com.github.mobile.android.util.AvatarHelper;
import com.madgag.android.listviews.ViewHolder;

import org.eclipse.egit.github.core.User;

/**
 * View holder to display a user/organization
 */
public class OrgViewHolder implements ViewHolder<User> {

    private final AvatarHelper avatarHelper;

    private final TextView nameText;

    private final ImageView avatarView;

    /**
     * Create org view holder
     *
     * @param view
     * @param avatarHelper
     */
    public OrgViewHolder(final View view, final AvatarHelper avatarHelper) {
        this.avatarHelper = avatarHelper;
        nameText = (TextView) view.findViewById(id.tv_org_name);
        avatarView = (ImageView) view.findViewById(id.iv_gravatar);
    }

    @Override
    public void updateViewFor(final User user) {
        nameText.setText(user.getLogin());
        avatarView.setBackgroundDrawable(null);
        avatarHelper.bind(avatarView, user);
    }
}

package com.github.mobile.android.repo;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.github.mobile.android.R.id;
import com.github.mobile.android.util.AvatarHelper;
import com.madgag.android.listviews.ViewHolder;

import org.eclipse.egit.github.core.User;

/**
 * View holder to display a user/organization
 */
public class OrgViewHolder implements ViewHolder<User> {

    private final AvatarHelper avatarHelper;

    private final TextView nameText;

    private final ImageView avatarView;

    /**
     * Create org view holder
     *
     * @param view
     * @param avatarHelper
     */
    public OrgViewHolder(final View view, final AvatarHelper avatarHelper) {
        this.avatarHelper = avatarHelper;
        nameText = (TextView) view.findViewById(id.tv_org_name);
        avatarView = (ImageView) view.findViewById(id.iv_gravatar);
    }

    @Override
    public void updateViewFor(final User user) {
        nameText.setText(user.getLogin());
        avatarHelper.bind(avatarView, user);
    }
}

Remove unneeded clearing of image view background drawable


package org.metaborg.spoofax.core.stratego.primitive.scopegraph;

import org.metaborg.scopegraph.context.IScopeGraphContext;
import org.metaborg.scopegraph.context.IScopeGraphUnit;
import org.metaborg.scopegraph.indices.TermIndex;
import org.metaborg.util.log.ILogger;
import org.metaborg.util.log.LoggerUtils;
import org.spoofax.interpreter.core.IContext;
import org.spoofax.interpreter.core.InterpreterException;
import org.spoofax.interpreter.stratego.Strategy;
import org.spoofax.interpreter.terms.IStrategoTerm;

public class SG_get_ast_analysis extends ScopeGraphPrimitive {

    private static final ILogger logger = LoggerUtils.logger(SG_get_ast_analysis.class);

    public SG_get_ast_analysis() {
        super(SG_get_ast_analysis.class.getSimpleName(), 0, 0);
    }

    @Override public boolean call(IScopeGraphContext<?> context, IContext env, Strategy[] strategies,
            IStrategoTerm[] terms) throws InterpreterException {
        final TermIndex index = TermIndex.get(env.current());
        if (index == null) {
            logger.warn("get-analysis called with non-AST argument {}", env.current());
            return false;
        }
        final IScopeGraphUnit unit = context.unit(index.resource());
        final IStrategoTerm analysis = unit.analysis();
        if (analysis == null) {
            return false;
        }
        env.setCurrent(analysis);
        return true;
    }

}

package org.metaborg.spoofax.core.stratego.primitive.scopegraph;

import org.metaborg.scopegraph.context.IScopeGraphContext;
import org.metaborg.scopegraph.context.IScopeGraphUnit;
import org.metaborg.scopegraph.indices.TermIndex;
import org.metaborg.util.log.ILogger;
import org.metaborg.util.log.LoggerUtils;
import org.spoofax.interpreter.core.IContext;
import org.spoofax.interpreter.core.InterpreterException;
import org.spoofax.interpreter.stratego.Strategy;
import org.spoofax.interpreter.terms.IStrategoTerm;

public class SG_get_ast_analysis extends ScopeGraphPrimitive {

    private static final ILogger logger = LoggerUtils.logger(SG_get_ast_analysis.class);

    public SG_get_ast_analysis() {
        super(SG_get_ast_analysis.class.getSimpleName(), 0, 0);
    }

    @Override public boolean call(IScopeGraphContext<?> context, IContext env, Strategy[] strategies,
            IStrategoTerm[] terms) throws InterpreterException {
        final TermIndex index = TermIndex.get(env.current());
        if (index == null) {
            logger.warn("get-ast-analysis called with non-AST argument {}", env.current());
            return false;
        }
        final IScopeGraphUnit unit = context.unit(index.resource());
        final IStrategoTerm analysis = unit.analysis();
        if (analysis == null) {
            return false;
        }
        env.setCurrent(analysis);
        return true;
    }

}

Fix strategy name in error message.


package utils.logging;

import java.util.logging.Formatter;
import java.util.logging.LogRecord;

public class L1Formatter extends Formatter{

	@Override
	public String format(LogRecord rec) {
		StringBuffer buf = new StringBuffer(1000);

		buf.append(formatMessage(rec));
		buf.append("\n\t\t\t\t\t (");
		buf.append(rec.getLevel());
		buf.append(" - ");
		buf.append(rec.getSourceClassName() + "#");
		buf.append(rec.getSourceMethodName());
		buf.append(")");
		buf.append("\n");

		return buf.toString();
	}
}

package utils.logging;

import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.LogRecord;

public class L1Formatter extends Formatter{
	// TODO: ansi colors are just a demo hack, here
public static final String ANSI_RESET = "\u001B[0m";
public static final String ANSI_BLACK = "\u001B[30m";
public static final String ANSI_RED = "\u001B[31m";
	@Override
	public String format(LogRecord rec) {
		StringBuffer buf = new StringBuffer(1000);

		if ( rec.getLevel() == Level.SEVERE) {
			buf.append(ANSI_RED);
		}

		buf.append(formatMessage(rec));
		if ( rec.getLevel() == Level.SEVERE) {
			buf.append(ANSI_RESET);
		}
		buf.append("\n\t\t\t\t\t (");
		buf.append(rec.getLevel());
		buf.append(" - ");
		buf.append(rec.getSourceClassName() + "#");
		buf.append(rec.getSourceMethodName());
		buf.append(")");
		buf.append("\n");

		return buf.toString();
	}
}

Add color output for type errors


// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.cloud.trace.sdk;

import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Common reflection utilities.
 */
public class ReflectionUtils {

  private static final Logger logger = Logger.getLogger(ReflectionUtils.class.getName());

  /**
   * Reflectively instantiates and initializes a TraceWriter using a Properties file.
   */
  public static Object createFromProperties(String className, Properties props) {
    Object obj = null;
    try {
      obj = Class.forName(className).newInstance();
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
      logger.log(Level.WARNING, "Error creating " + className, e);
    }
    if (obj != null && obj instanceof CanInitFromProperties) {
      ((CanInitFromProperties) obj).initFromProperties(props);
    }
    return obj;
  }
}

// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.cloud.trace.sdk;

import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Common reflection utilities.
 */
public class ReflectionUtils {

  private static final Logger logger = Logger.getLogger(ReflectionUtils.class.getName());

  /**
   * Reflectively instantiates and initializes a class using a Properties file.
   */
  public static Object createFromProperties(String className, Properties props) {
    Object obj = null;
    try {
      obj = Class.forName(className).newInstance();
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
      logger.log(Level.WARNING, "Error creating " + className, e);
    }
    if (obj != null && obj instanceof CanInitFromProperties) {
      ((CanInitFromProperties) obj).initFromProperties(props);
    }
    return obj;
  }
}

Fix bogus Javadoc comment that referred to TraceWriter.


package org.mozartoz.truffle;

import org.mozartoz.truffle.translator.Loader;

import com.oracle.truffle.api.source.Source;

public class Main {

	private static final String BASE_TESTS = Loader.MOZART2_DIR + "/platform-test/base/";

	private static final String[] PASSING_TESTS = {
			BASE_TESTS + "int.oz",
			BASE_TESTS + "dictionary.oz",
			BASE_TESTS + "record.oz",
			BASE_TESTS + "state.oz",
			BASE_TESTS + "exception.oz",
			BASE_TESTS + "float.oz",
			BASE_TESTS + "conversion.oz",
			BASE_TESTS + "type.oz",
	};

	public static void main(String[] args) {
		// Source source = Loader.createSource("test.oz");
		// Loader.getInstance().run(source);

		Source source = Loader.createSource("simple_runner.oz");
		Loader.getInstance().runFunctor(source, PASSING_TESTS);
	}

}

package org.mozartoz.truffle;

import org.mozartoz.truffle.translator.Loader;

import com.oracle.truffle.api.source.Source;

public class Main {

	private static final String BASE_TESTS = Loader.MOZART2_DIR + "/platform-test/base/";
	private static final String TEST_RUNNER = Loader.MOZART2_DIR + "/platform-test/simple_runner.oz";

	private static final String[] PASSING_TESTS = {
			BASE_TESTS + "int.oz",
			BASE_TESTS + "dictionary.oz",
			BASE_TESTS + "record.oz",
			BASE_TESTS + "state.oz",
			BASE_TESTS + "exception.oz",
			BASE_TESTS + "float.oz",
			BASE_TESTS + "conversion.oz",
			BASE_TESTS + "type.oz",
	};

	public static void main(String[] args) {
		// Source source = Loader.createSource("test.oz");
		// Loader.getInstance().run(source);

		Source source = Loader.createSource(TEST_RUNNER);
		Loader.getInstance().runFunctor(source, PASSING_TESTS);
	}

}

Use simple_runner from the platform-test dir


package fi.haippirinki.l2p;

public class MainActivity extends android.app.NativeActivity {
}

package fi.haippirinki.l2p;

import android.os.Build;
import android.view.View;

public class MainActivity extends android.app.NativeActivity {
	protected void onCreate(android.os.Bundle savedInstanceState) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
                View.SYSTEM_UI_FLAG_FULLSCREEN |
                View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }

        super.onCreate(savedInstanceState);
    }
}

Set fullscreen flags if on api 19 or newer.


package net.safedata.springboot.training.d03.s01;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * Spring {@link Configuration} which loads some beans conditionally
 *
 * @author bogdan.solga
 */
@Configuration
public class ConditionalBeansConfig {

    @Bean
    @ConditionalOnClass(DataSource.class)
    public String conditionalOnClass() {
        return "Conditional on the DataSource class";
    }

    @Bean
    @ConditionalOnProperty(name = "matching.property", havingValue = "true")
    public String conditionalOnProperty() {
        return "Conditional on a property";
    }

    @Bean
    @ConditionalOnProperty(name = "used.webserver", havingValue = "jetty")
    public EmbeddedServletContainer jetty() {
        return new JettyEmbeddedServletContainer(null, true);
    }

    // a 'feature toggle' sample approach
    @Bean
    @ConditionalOnProperty(name = "cool.feature", havingValue = "enabled")
    public Object coolFeature() {
        return new Object();
    }
}

package net.safedata.springboot.training.d03.s01;

import org.eclipse.jetty.server.Server;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * Spring {@link Configuration} which loads some beans conditionally
 *
 * @author bogdan.solga
 */
@Configuration
public class ConditionalBeansConfig {

    @Bean
    @ConditionalOnClass(DataSource.class)
    public String conditionalOnClass() {
        return "Conditional on the DataSource class";
    }

    @Bean
    @ConditionalOnProperty(
            name = "enable.important.and.experimental.feature",
    		havingValue = "true"
	)
    public String conditionalOnProperty() {
        System.out.println("Enabling our important [and experimental] feature...");
        return "Conditional on a property";
    }

    @Bean
    @ConditionalOnProperty(
    		name = "used.webserver",
    		havingValue = "jetty"
	)
    public EmbeddedServletContainer jetty() {
        return new JettyEmbeddedServletContainer(new Server(9999), true);
    }

    // a 'feature toggle' sample approach
    @Bean
    @ConditionalOnProperty(
            name = "cool.feature",
            havingValue = "enabled"
    )
    public Object coolFeature() {
        return new Object();
    }
}

Split the conditional annotations on new lines


package io.burt.jmespath.function;

import java.util.List;
import java.util.Arrays;

import io.burt.jmespath.Adapter;
import io.burt.jmespath.JmesPathType;

public class ToArrayFunction extends BaseFunction {
  public ToArrayFunction() {
    super(ArgumentConstraints.anyValue());
  }

  @Override
  protected <T> T callFunction(Adapter<T> runtime, List<FunctionArgument<T>> arguments) {
    T subject = arguments.get(0).value();
    if (runtime.typeOf(subject) == JmesPathType.ARRAY) {
      return subject;
    } else {
      return runtime.createArray(Arrays.asList(subject));
    }
  }
}

package io.burt.jmespath.function;

import java.util.Collections;
import java.util.List;
import java.util.Arrays;

import io.burt.jmespath.Adapter;
import io.burt.jmespath.JmesPathType;

public class ToArrayFunction extends BaseFunction {
  public ToArrayFunction() {
    super(ArgumentConstraints.anyValue());
  }

  @Override
  protected <T> T callFunction(Adapter<T> runtime, List<FunctionArgument<T>> arguments) {
    T subject = arguments.get(0).value();
    if (runtime.typeOf(subject) == JmesPathType.ARRAY) {
      return subject;
    } else {
      return runtime.createArray(Collections.singletonList(subject));
    }
  }
}

Use the right kind of list creating method to show the correct intent


package piano;

import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;

/**
 * Tone player.
 *
 * @author Wincent Balin
 */
public class TonePlayer implements NotePlayer
{
    public static final int TONE_DURATION = 333;

    private PianoModel model;

    /**
     * Constructor.
     *
     * @param model Model to work with
     */
    TonePlayer(PianoModel model)
    {
        this.model = model;
    }
    /**
     * Implementation of NotePlayer.
     */
    public void update()
    {
        while(model.hasMoreNoteEvents())
        {
            NoteEvent ev = model.nextNoteEvent();

            if(ev.getCode() == NoteEvent.NOTE_ON)
            {
                try
                {
                    Manager.playTone(ev.getNote(),
                                     TONE_DURATION,
                                     ev.getVelocity());
                }
                catch(MediaException e)
                {
                }
            }
        }
    }
}

package piano;

import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;

/**
 * Tone player.
 *
 * @author Wincent Balin
 */
public class TonePlayer implements NotePlayer
{
    public static final int TONE_DURATION = 333;

    private PianoModel model;

    /**
     * Constructor.
     *
     * @param model Model to work with
     */
    TonePlayer(PianoModel model)
    {
        this.model = model;
    }
    /**
     * Implementation of NotePlayer.
     */
    public void update()
    {
        while(model.hasMoreNoteEvents())
        {
            NoteEvent ev = model.nextNoteEvent();

            if(ev.getCode() == NoteEvent.NOTE_ON)
            {
                try
                {
                    Manager.playTone(ev.getNote(),
                                     TONE_DURATION,
                                     (ev.getVelocity() * 100) / 127);
                }
                catch(MediaException e)
                {
                }
            }
        }
    }
}

Adjust velocity from MIDI to tone


package org.junit.experimental.categories;

import java.util.ArrayList;
import java.util.List;

import org.junit.internal.Classes;
import org.junit.runner.FilterFactory;
import org.junit.runner.FilterFactoryParams;
import org.junit.runner.manipulation.Filter;

/**
 * Implementation of FilterFactory for Category filtering.
 */
abstract class CategoryFilterFactory implements FilterFactory {
    /**
     * Creates a {@link org.junit.experimental.categories.Categories.CategoryFilter} given a
     * {@link FilterFactoryParams} argument.
     *
     * @param params Parameters needed to create the {@link Filter}
     * @throws FilterNotCreatedException
     */
    @Override
    public Filter createFilter(FilterFactoryParams params) throws FilterNotCreatedException {
        try {
            return createFilter(parseCategories(params.getArgs()));
        } catch (ClassNotFoundException e) {
            throw new FilterNotCreatedException(e);
        }
    }

    /**
     * Creates a {@link org.junit.experimental.categories.Categories.CategoryFilter} given an array of classes.
     *
     * @param categories Category classes.
     */
    protected abstract Filter createFilter(Class<?>... categories);

    private Class<?>[] parseCategories(String categories) throws ClassNotFoundException {
        List<Class<?>> categoryClasses = new ArrayList<Class<?>>();

        for (String category : categories.split(",")) {
            Class<?> categoryClass = Classes.getClass(category);

            categoryClasses.add(categoryClass);
        }

        return categoryClasses.toArray(new Class[]{});
    }
}

package org.junit.experimental.categories;

import java.util.ArrayList;
import java.util.List;

import org.junit.internal.Classes;
import org.junit.runner.FilterFactory;
import org.junit.runner.FilterFactoryParams;
import org.junit.runner.manipulation.Filter;

/**
 * Implementation of FilterFactory for Category filtering.
 */
abstract class CategoryFilterFactory implements FilterFactory {
    /**
     * Creates a {@link org.junit.experimental.categories.Categories.CategoryFilter} given a
     * {@link FilterFactoryParams} argument.
     *
     * @param params Parameters needed to create the {@link Filter}
     * @throws FilterNotCreatedException
     */
    public Filter createFilter(FilterFactoryParams params) throws FilterNotCreatedException {
        try {
            return createFilter(parseCategories(params.getArgs()));
        } catch (ClassNotFoundException e) {
            throw new FilterNotCreatedException(e);
        }
    }

    /**
     * Creates a {@link org.junit.experimental.categories.Categories.CategoryFilter} given an array of classes.
     *
     * @param categories Category classes.
     */
    protected abstract Filter createFilter(Class<?>... categories);

    private Class<?>[] parseCategories(String categories) throws ClassNotFoundException {
        List<Class<?>> categoryClasses = new ArrayList<Class<?>>();

        for (String category : categories.split(",")) {
            Class<?> categoryClass = Classes.getClass(category);

            categoryClasses.add(categoryClass);
        }

        return categoryClasses.toArray(new Class[]{});
    }
}

Make compilable under Java 1.5.


package com.example.mwismer.mobproto_finalproject;

import android.app.Fragment;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created by mwismer on 10/23/14.
 */
public class MyFragment extends Fragment {
    private String TAG = "MyFragment";

    public MyFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_my, container, false);

        new BLEScanner(getActivity()).scanBLE();

        return rootView;
    }
}

package com.example.mwismer.mobproto_finalproject;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by mwismer on 10/23/14.
 */
public class MyFragment extends Fragment {
    private String TAG = "MyFragment";

    public MyFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_my, container, false);

        new BLEScanner(getActivity()).scanBLE();

        return rootView;
    }
}

Remove unused imports from MyActivity


/**
 * A palindromic number reads the same both ways.
 * The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
 *
 * Find the largest palindrome made from the product of two 3-digit numbers.
 *
 * @author David Clutter
 */
public class Problem0004 {

    public static void main(final String[] args) {
        long largestPalindrome = 0;
        for(int i = 100; i < 1000; ++i) {
            for(int j = 100; j < 1000; ++j) {
                final long product = i * j;
                if(Utilities.isPalindrome(product) && product > largestPalindrome) {
                    largestPalindrome = product;
                }
            }
        }
        System.out.println(largestPalindrome);
    }
}

import java.util.stream.LongStream;

/**
 * A palindromic number reads the same both ways.
 * The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
 * <p>
 * Find the largest palindrome made from the product of two 3-digit numbers.
 *
 * @author David Clutter
 */
public class Problem0004 {

    public static void main(final String[] args) {

        final long largestPalindrome = LongStream.range(100, 1_000)
                .flatMap(i ->
                        LongStream.range(100, 1_000)
                                .map(j -> i * j))
                .filter(Utilities::isPalindrome)
                .max()
                .getAsLong();
        System.out.println(largestPalindrome);
    }
}

Update problem0004 to use streams


/*
 * Copyright 2000-2017 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.intellij.plugins.hil.codeinsight;

import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
import org.intellij.plugins.hil.inspection.HILUnresolvedReferenceInspection;
import org.jetbrains.annotations.NotNull;

public class AddVariableTest extends LightQuickFixTestCase {

  @NotNull
  @Override
  protected String getTestDataPath() {
    return "test-data/hil/codeinsight/add-variable/";
  }

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    enableInspectionTools(HILUnresolvedReferenceInspection.class);
  }

  public void testSimpleVariable() throws Exception {
    doSingleTest();
  }

  private void doSingleTest() {
    doSingleTest(getTestName(false) + ".tf");
  }
}

/*
 * Copyright 2000-2017 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.intellij.plugins.hil.codeinsight;

import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
import org.intellij.plugins.hil.inspection.HILUnresolvedReferenceInspection;
import org.jetbrains.annotations.NotNull;

public class AddVariableTest extends LightQuickFixTestCase {

  @NotNull
  @Override
  protected String getTestDataPath() {
    return "test-data/hil/codeinsight/add-variable/";
  }

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    enableInspectionTools(new HILUnresolvedReferenceInspection());
  }

  public void testSimpleVariable() throws Exception {
    doSingleTest();
  }

  private void doSingleTest() {
    doSingleTest(getTestName(false) + ".tf");
  }
}

Fix tests compile compatibility with 2017.1.2


package de.bowstreet.testandroidapp;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.microsoft.azure.mobile.MobileCenter;
import com.microsoft.azure.mobile.analytics.Analytics;
import com.microsoft.azure.mobile.crashes.Crashes;

public class MainActivity extends AppCompatActivity {

    private Button mButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        MobileCenter.start(getApplication(), "2f85b1e5-f98d-4d7f-95f0-3509876fa2dd", Analytics.class, Crashes.class);

        mButton = (Button) findViewById(R.id.button);
        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                throw new RuntimeException("Test exception");
            }
        });
    }
}

package de.bowstreet.testandroidapp;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.microsoft.azure.mobile.MobileCenter;
import com.microsoft.azure.mobile.analytics.Analytics;
import com.microsoft.azure.mobile.crashes.Crashes;

public class MainActivity extends AppCompatActivity {

    private Button mButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        MobileCenter.start(getApplication(), "675da273-5716-4855-9dd0-431fe51ebfef", Analytics.class, Crashes.class);

        mButton = (Button) findViewById(R.id.button);
        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                throw new RuntimeException("Test exception");
            }
        });
    }
}

Use app secret for prod app


package darkevilmac.movingworld.asm.mixin.core.entity;

import net.minecraft.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

/**
 * Override minecraft's move methods so we can tell it how to handle collision.
 */
@Mixin(Entity.class)
public class MixinEntity {

    @Inject(method = "moveEntity(DDD)V", at = @At("HEAD"), cancellable = true)
    public void onMoveEntity(double x, double y, double z, CallbackInfo ci) {
        // Does nothing currently.
    }

}

package darkevilmac.movingworld.asm.mixin.core.entity;

import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.List;

/**
 * Override Minecraft's move methods so we can tell it how to handle collision.
 */
@Mixin(Entity.class)
public class MixinEntity {

    @Inject(method = "moveEntity(DDD)V", at = @At("INVOKE"), cancellable = true)
    public void onMoveEntity(double x, double y, double z, CallbackInfo ci) {
        Entity thisEntity = (Entity) (Object) this;
        World worldObj = thisEntity.worldObj;

        // If this entity is in noClip just let the method do it's stuff.
        if (thisEntity.noClip)
            return;

        AxisAlignedBB boundingBox = new AxisAlignedBB(thisEntity.posX - 3, thisEntity.posY - 5, thisEntity.posZ - 3,
                thisEntity.posX + 3, thisEntity.posY + 5, thisEntity.posZ + 3);
        List<Entity> movingWorldsInBox = worldObj.getEntitiesWithinAABBExcludingEntity(thisEntity, boundingBox);

        if (movingWorldsInBox != null && !movingWorldsInBox.isEmpty()) {

        }
    }

}

Add nearby ship detection to moveEntity