package client.command;

public enum Commands {

    Username(new String[]{"/username", "/name", "/u"}, Username.class),
    Team(new String[]{"/team", "/t"}, Team.class),
    Contract(new String[]{"/contract"}, Contract.class),
    Create(new String[]{"/create", "/c"}, Create.class),
    Join(new String[]{"/join", "/j"}, Join.class),
    ListPlayers(new String[]{"/list-players"}, ListPlayers.class),
    ListChannel(new String[]{"/list-channel"}, ListChannel.class),
    Leave(new String[]{"/leave", "/l"}, Leave.class),
    ShowCards(new String[]{"/show-cards"}, ShowCards.class),
    ShowTable(new String[]{"/show-table"}, ShowTable.class),
    PlayCard(new String[]{"/play"}, PlayCard.class),
    ShowContract(new String[]{"/show-contract"}, ShowContract.class);

    private String[] aliases;
    private Class command;

    Commands(String[] aliases, Class command) {
        this.aliases = aliases;
        this.command = command;
    }

    public static Class from(String text) throws Exception {
        for (Commands command : Commands.values()) {
            for (String alias : command.getAliases()) {
                if (text.startsWith(alias)) {
                    return command.getCommand();
                }
            }
        }
        throw new Exception();
    }

    public String[] getAliases() {
        return this.aliases;
    }

    public Class getCommand() {
        return this.command;
    }

}

package client.command;

public enum Commands {

    Username(new String[]{"/username", "/name", "/u"}, Username.class),
    Team(new String[]{"/team", "/t"}, Team.class),
    Contract(new String[]{"/contract"}, Contract.class),
    Create(new String[]{"/create", "/c"}, Create.class),
    Join(new String[]{"/join", "/j"}, Join.class),
    ListPlayers(new String[]{"/list-players"}, ListPlayers.class),
    ListChannel(new String[]{"/list-channel"}, ListChannel.class),
    Leave(new String[]{"/leave", "/l"}, Leave.class),
    ShowCards(new String[]{"/show-cards"}, ShowCards.class),
    ShowTable(new String[]{"/show-table"}, ShowTable.class),
    PlayCard(new String[]{"/play"}, PlayCard.class),
    ShowContract(new String[]{"/show-contract"}, ShowContract.class);

    private String[] aliases;
    private Class command;

    Commands(String[] aliases, Class command) {
        this.aliases = aliases;
        this.command = command;
    }

    public static Class from(String text) throws Exception {
        for (Commands command : Commands.values()) {
            for (String alias : command.getAliases()) {
                if (text.startsWith(alias + ' ')) {
                    return command.getCommand();
                }
            }
        }
        throw new Exception();
    }

    public String[] getAliases() {
        return this.aliases;
    }

    public Class getCommand() {
        return this.command;
    }

}

Fix a bug when a command like "/list-players" is miss-spelled and "/leave" is executed cause of its alias "/l".


package math;

public class DivideByZeroException
    extends
      Exception
{
  public DivideByZeroException(String reason){
    super(reason);
  }

  public DivideByZeroException(){
    super();
  }

  public String printException(){
    return "Divide by zero!";
  }
}

package math;

public class DivideByZeroException
    extends
      Exception
{
  /**
   *
   */
  private static final long serialVersionUID = 1L;

  /*
   * @param String reason
   * @purpose calls super constructor of same param
   */
  public DivideByZeroException(String reason){
    super(reason);
  } // DivideByZeroException(String)

  /*
   * @purpose calls super constructor of same param
   */
  public DivideByZeroException(){
    super();
  }// DivideByZeroException()

  /*
   * @purpose returns customized message
   */
  public String printException(){
    return "Divide by zero!";
  } // printException()
} // class DivideByZeroException

Add comments for custom exception


/*
 * Copyright 2010 Proofpoint, 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 com.proofpoint.jmx;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;

final class NetUtils
{
    private NetUtils()
    {
    }

    public static int findUnusedPort()
            throws IOException
    {
        int port;

        ServerSocket socket = new ServerSocket();
        try {
            socket.bind(new InetSocketAddress(0));
            port = socket.getLocalPort();
        }
        finally {
            socket.close();
        }

        return port;
    }
}

/*
 * Copyright 2010 Proofpoint, 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 com.proofpoint.jmx;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;

final class NetUtils
{
    private NetUtils()
    {
    }

    public static int findUnusedPort()
            throws IOException
    {
        int port;

        try (ServerSocket socket = new ServerSocket()) {
            socket.bind(new InetSocketAddress(0));
            port = socket.getLocalPort();
        }

        return port;
    }
}

Use try-with-resources instead of try/finally


import java.util.*;
import org.xbill.DNS.*;

public class lookup {

public static void
printAnswer(String name, Lookup lookup) {
	System.out.print(name + ":");
	int result = lookup.getResult();
	if (result != Lookup.SUCCESSFUL)
		System.out.print(" " + lookup.getErrorString());
	System.out.println();
	if (lookup.getResult() == Lookup.SUCCESSFUL) {
		Record [] answers = lookup.getAnswers();
		for (int i = 0; i < answers.length; i++)
			System.out.println(answers[i]);
	}
}

public static void
main(String [] args) throws Exception {
	short type = Type.A;
	int start = 0;
	if (args.length > 2 && args[0].equals("-t")) {
		type = Type.value(args[1]);
		if (type < 0)
			throw new IllegalArgumentException("invalid type");
		start = 2;
	}
	for (int i = start; i < args.length; i++) {
		Lookup l = new Lookup(args[i], type);
		l.run();
		printAnswer(args[i], l);
	}
}

}

import java.util.*;
import org.xbill.DNS.*;

public class lookup {

public static void
printAnswer(String name, Lookup lookup) {
	System.out.print(name + ":");
	int result = lookup.getResult();
	if (result != Lookup.SUCCESSFUL)
		System.out.print(" " + lookup.getErrorString());
	System.out.println();
	Name [] aliases = lookup.getAliases();
	if (aliases.length > 0) {
		System.out.print("# aliases: ");
		for (int i = 0; i < aliases.length; i++) {
			System.out.print(aliases[i]);
			if (i < aliases.length - 1)
				System.out.print(" ");
		}
		System.out.println();
	}
	if (lookup.getResult() == Lookup.SUCCESSFUL) {
		Record [] answers = lookup.getAnswers();
		for (int i = 0; i < answers.length; i++)
			System.out.println(answers[i]);
	}
}

public static void
main(String [] args) throws Exception {
	short type = Type.A;
	int start = 0;
	if (args.length > 2 && args[0].equals("-t")) {
		type = Type.value(args[1]);
		if (type < 0)
			throw new IllegalArgumentException("invalid type");
		start = 2;
	}
	for (int i = start; i < args.length; i++) {
		Lookup l = new Lookup(args[i], type);
		l.run();
		printAnswer(args[i], l);
	}
}

}

Print a list of aliases, if any exist.


package org.ovirt.engine.core.compat.backendcompat;

import java.beans.PropertyDescriptor;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

//This will be a wrapper for import java.beans.PropertyDescriptor;
public class PropertyInfo {
    private static Log log = LogFactory.getLog(PropertyInfo.class);

    private PropertyDescriptor pd;

    public PropertyInfo(PropertyDescriptor pd) {
        this.pd = pd;
    }

    public String getName() {
        return pd.getName();
    }

    public Object GetValue(Object obj, Object defaultValue) {
        Object returnValue = null;
        try {
            returnValue = pd.getReadMethod().invoke(obj);
        } catch (Exception e) {
            log.warn("Unable to get value of property: " + pd.getDisplayName() + " for class "
                    + obj.getClass().getName());
        }
        return returnValue == null ? defaultValue : returnValue;
    }

    public boolean getCanWrite() {
        return pd.getWriteMethod() != null;
    }

    public boolean isPropertyInstanceOf(Class<?> clazz) {
        return this.pd.getPropertyType().equals(clazz);
    }
}

package org.ovirt.engine.core.compat.backendcompat;

import java.beans.PropertyDescriptor;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

//This will be a wrapper for import java.beans.PropertyDescriptor;
public class PropertyInfo {
    private static final Log log = LogFactory.getLog(PropertyInfo.class);

    private PropertyDescriptor pd;

    public PropertyInfo(PropertyDescriptor pd) {
        this.pd = pd;
    }

    public String getName() {
        return pd.getName();
    }

    public Object GetValue(Object obj, Object defaultValue) {
        Object returnValue = null;
        try {
            returnValue = pd.getReadMethod().invoke(obj);
        } catch (Exception e) {
            log.warn("Unable to get value of property: " + pd.getDisplayName() + " for class "
                    + obj.getClass().getName());
        }
        return returnValue == null ? defaultValue : returnValue;
    }

    public boolean getCanWrite() {
        return pd.getWriteMethod() != null;
    }

    public boolean isPropertyInstanceOf(Class<?> clazz) {
        return this.pd.getPropertyType().equals(clazz);
    }
}

Fix log modifiers in PropretyInfo


package example.springdata.jdbc.howto.idgeneration;

import java.util.UUID;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.relational.core.mapping.event.BeforeSaveCallback;

@SpringBootApplication
class IdGenerationApplication {

	public static void main(String[] args) {
		SpringApplication.run(IdGenerationApplication.class, args);
	}

	@Bean
	BeforeSaveCallback<StringIdMinion> beforeSaveCallback() {

		return (minion, mutableAggregateChange) -> {
			if (minion.id == null) {
				minion.id = UUID.randomUUID().toString();
			}
			return minion;
		};
	}

}

package example.springdata.jdbc.howto.idgeneration;

import java.util.UUID;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.relational.core.mapping.event.BeforeConvertCallback;

@SpringBootApplication
class IdGenerationApplication {

	public static void main(String[] args) {
		SpringApplication.run(IdGenerationApplication.class, args);
	}

	@Bean
	BeforeConvertCallback<StringIdMinion> beforeSaveCallback() {

		return (minion) -> {
			if (minion.id == null) {
				minion.id = UUID.randomUUID().toString();
			}
			return minion;
		};
	}

}

Use BeforeConvertCallback to generate entity identifiers.


package com.novoda.downloadmanager;

import android.support.annotation.Nullable;

import com.novoda.notils.logger.simple.Log;

final class WaitForDownloadServiceThenPerform {

    interface Action<T> {
        T performAction();
    }

    private WaitForDownloadServiceThenPerform() {
        // Uses static factory method.
    }

    static <T> WaitForDownloadServiceThenPerformAction<T> waitFor(@Nullable DownloadService downloadService, Object downloadServiceLock) {
        return new WaitForDownloadServiceThenPerformAction<>(downloadService, downloadServiceLock);
    }

    static class WaitForDownloadServiceThenPerformAction<T> {

        private final DownloadService downloadService;
        private final Object lock;

        WaitForDownloadServiceThenPerformAction(DownloadService downloadService, Object lock) {
            this.downloadService = downloadService;
            this.lock = lock;
        }

        T thenPerform(final Action<T> action) {
            if (downloadService == null) {
                try {
                    synchronized (lock) {
                        lock.wait();
                    }
                } catch (InterruptedException e) {
                    Log.e(e, "Interrupted waiting for download service.");
                }
            }
            return action.performAction();
        }

    }

}

package com.novoda.downloadmanager;

import android.support.annotation.Nullable;

import com.novoda.notils.logger.simple.Log;

final class WaitForDownloadServiceThenPerform {

    interface Action<T> {
        T performAction();
    }

    private WaitForDownloadServiceThenPerform() {
        // Uses static factory method.
    }

    static <T> WaitForDownloadServiceThenPerformAction<T> waitFor(@Nullable DownloadService downloadService, Object downloadServiceLock) {
        return new WaitForDownloadServiceThenPerformAction<>(downloadService, downloadServiceLock);
    }

    static class WaitForDownloadServiceThenPerformAction<T> {

        private final DownloadService downloadService;
        private final Object downloadServiceLock;

        WaitForDownloadServiceThenPerformAction(DownloadService downloadService, Object downloadServiceLock) {
            this.downloadService = downloadService;
            this.downloadServiceLock = downloadServiceLock;
        }

        T thenPerform(final Action<T> action) {
            if (downloadService == null) {
                waitForLock();
            }
            return action.performAction();
        }

        private void waitForLock() {
            try {
                synchronized (downloadServiceLock) {
                    if (downloadService == null) {
                        downloadServiceLock.wait();
                    }
                }
            } catch (InterruptedException e) {
                Log.e(e, "Interrupted waiting for download service.");
            }
        }

    }

}

Add conditional before wait statement in synchronize block.


/**
 * Copyright (C) 2015 android10.org. All rights reserved.
 * @author Fernando Cejas (the android10 coder)
 */
package com.fernandocejas.android10.sample.presentation.internal.di.modules;

import android.app.Activity;
import android.content.Context;
import com.fernandocejas.android10.sample.presentation.internal.di.PerActivity;
import dagger.Module;
import dagger.Provides;

/**
 * A module to wrap the Activity state and expose it to the graph.
 */
@Module
public class ActivityModule {
  private final Activity activity;

  public ActivityModule(Activity activity) {
    this.activity = activity;
  }

  /**
  * Expose the activity to dependents in the graph.
  */
  @Provides @PerActivity Activity activity() {
    return this.activity;
  }

  @Provides @PerActivity Context provideActivityContext() {
    return this.activity;
  }
}

/**
 * Copyright (C) 2015 android10.org. All rights reserved.
 * @author Fernando Cejas (the android10 coder)
 */
package com.fernandocejas.android10.sample.presentation.internal.di.modules;

import android.app.Activity;
import com.fernandocejas.android10.sample.presentation.internal.di.PerActivity;
import dagger.Module;
import dagger.Provides;

/**
 * A module to wrap the Activity state and expose it to the graph.
 */
@Module
public class ActivityModule {
  private final Activity activity;

  public ActivityModule(Activity activity) {
    this.activity = activity;
  }

  /**
  * Expose the activity to dependents in the graph.
  */
  @Provides @PerActivity Activity activity() {
    return this.activity;
  }
}

Remove unused Context provide method.


package com.google.android.stardroid.units;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;

import static junit.framework.Assert.assertEquals;

/**
 * Tests that require roboelectric for API calls.
 */
@RunWith(RobolectricTestRunner.class)
public class LatLongRoboTest {

    @Test
    public void latLong_testDistance() {
        LatLong point1 = new LatLong(0, 0);
        LatLong point2 = new LatLong(95, 0);
        assertEquals(90f, point1.distanceFrom(point2));
    }
}

package com.google.android.stardroid.units;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static junit.framework.Assert.assertEquals;

/**
 * Tests that require roboelectric for API calls.
 */
@RunWith(RobolectricTestRunner.class)
@Config(manifest=Config.NONE)
public class LatLongRoboTest {

    @Test
    public void latLong_testDistance() {
        LatLong point1 = new LatLong(0, 0);
        LatLong point2 = new LatLong(90, 0);
        assertEquals(90f, point1.distanceFrom(point2));
    }

    @Test
    public void latLong_testDistance2() {
        LatLong point1 = new LatLong(45, 45);
        LatLong point2 = new LatLong(90, 0);
        assertEquals(45f, point1.distanceFrom(point2), 0.05);
    }

}

Add one more test for lat long fix.


/*
 * FindBugs - Find bugs in Java programs
 * Copyright (C) 2008, University of Maryland
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package edu.umd.cs.findbugs.annotations;

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

/**
 * Mark a constructor or method as creating a resource
 * which requires cleanup.
 * The marked method must be a member of a class
 * marked with the CleanupObligation annotation.
 *
 * @author David Hovemeyer
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CreatesObligation {

}

/*
 * FindBugs - Find bugs in Java programs
 * Copyright (C) 2008, University of Maryland
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package edu.umd.cs.findbugs.annotations;

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

/**
 * Mark a constructor or method as creating a resource
 * which requires cleanup.
 * The marked method must be a member of a class
 * marked with the CleanupObligation annotation.
 *
 * @author David Hovemeyer
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
public @interface CreatesObligation {

}

Allow to be applied to constructors


package uk.ac.eeci;

import io.improbable.scienceos.Conductor;
import org.apache.commons.cli.*;

public class CommandLineInterface {

    private String inputFilePath;
    private String outputFilePath;

    public static void main(String ... args) {

        Options options = new Options();

        Option input = new Option("i", "input", true, "file path to scenario db");
        input.setRequired(true);
        options.addOption(input);

        Option output = new Option("o", "output", true, "file path for output db");
        output.setRequired(true);
        options.addOption(output);

        CommandLineParser parser = new DefaultParser();
        HelpFormatter formatter = new HelpFormatter();
        CommandLine cmd;

        try {
            cmd = parser.parse(options, args);
        } catch (ParseException e) {
            System.out.println(e.getMessage());
            formatter.printHelp("energy-agents", options);

            System.exit(1);
            return;
        }

        CommandLineInterface cli = new CommandLineInterface();
        cli.inputFilePath = cmd.getOptionValue("input");
        cli.outputFilePath = cmd.getOptionValue("output");
        cli.run();
    }

    private void run() {
        CitySimulation citySimulation = ScenarioBuilder.readScenario(this.inputFilePath, this.outputFilePath);
        new Conductor(citySimulation).run();
    }
}

package uk.ac.eeci;

import io.improbable.scienceos.Conductor;
import io.improbable.scienceos.Reference;
import io.improbable.scienceos.WorkerPool;
import org.apache.commons.cli.*;

public class CommandLineInterface {

    private String inputFilePath;
    private String outputFilePath;

    public static void main(String ... args) {

        Options options = new Options();

        Option input = new Option("i", "input", true, "file path to scenario db");
        input.setRequired(true);
        options.addOption(input);

        Option output = new Option("o", "output", true, "file path for output db");
        output.setRequired(true);
        options.addOption(output);

        CommandLineParser parser = new DefaultParser();
        HelpFormatter formatter = new HelpFormatter();
        CommandLine cmd;

        try {
            cmd = parser.parse(options, args);
        } catch (ParseException e) {
            System.out.println(e.getMessage());
            formatter.printHelp("energy-agents", options);

            System.exit(1);
            return;
        }

        CommandLineInterface cli = new CommandLineInterface();
        cli.inputFilePath = cmd.getOptionValue("input");
        cli.outputFilePath = cmd.getOptionValue("output");
        cli.run();
    }

    private void run() {
        Reference.pool = new WorkerPool(4); // FIXME shouldnt be here
        Reference.pool.setCurrentExecutor(Reference.pool.main); // FIXME shouldnt be here
        CitySimulation citySimulation = ScenarioBuilder.readScenario(this.inputFilePath, this.outputFilePath);
        new Conductor(citySimulation).run();
    }
}

Add scienceos init to command line interface


package org.eclipse.birt.report.engine.api.script.instance;

public interface IReportItemInstance extends IReportElementInstance
{

	/**
	 * Get the hyperlink
	 *
	 * @return the hyperlink
	 */
	String getHyperlink( );

	/**
	 * Get the name
	 */
	String getName( );

	/**
	 * Get the name
	 */
	void setName( String name );

	/**
	 * Get the help text
	 */
	String getHelpText( );

	/**
	 * Get the help text
	 */
	void setHelpText( String helpText );

}

package org.eclipse.birt.report.engine.api.script.instance;

public interface IReportItemInstance extends IReportElementInstance
{

	/**
	 * Get the hyperlink
	 *
	 * @return the hyperlink
	 */
	String getHyperlink( );

	/**
	 * Get the name
	 */
	String getName( );

	/**
	 * Set the name
	 */
	void setName( String name );

	/**
	 * Get the help text
	 */
	String getHelpText( );

	/**
	 * Set the help text
	 */
	void setHelpText( String helpText );

}

Use "Set the XXX" instead of "Get the XXX" in the Javadoc before setXXX()


package com.quexten.ravtech.ui;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.kotcrab.vis.ui.VisUI;
import com.quexten.ravtech.RavTech;
import com.quexten.ravtech.util.Debug;

public class RavUI {

	Stage screenStage = new Stage(new ScreenViewport());
	public DebugConsole debugConsole;

	public RavUI () {
		if (!RavTech.isEditor)
			return;
		if (!VisUI.isLoaded())
			VisUI.load(Gdx.files.internal("mdpi/uiskin.json"));
		debugConsole = new DebugConsole();
		RavTech.input.addInputProcessor(screenStage);
		screenStage.addListener(new InputListener() {
			@Override
			public boolean keyDown (InputEvent event, int key) {
				if (key == Keys.F1)
					debugConsole.toggleVisible();
				return true;
			}
		});
		screenStage.addActor(debugConsole);
	}

	public void render () {
		screenStage.act();
		screenStage.draw();
	}

	public Stage getStage () {
		return screenStage;
	}

}

package com.quexten.ravtech.ui;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.kotcrab.vis.ui.VisUI;
import com.quexten.ravtech.RavTech;
import com.quexten.ravtech.util.Debug;

public class RavUI {

	Stage screenStage = new Stage(new ScreenViewport());
	public DebugConsole debugConsole;

	public RavUI () {
		if (!VisUI.isLoaded())
			VisUI.load(Gdx.files.internal("mdpi/uiskin.json"));
		debugConsole = new DebugConsole();
		RavTech.input.addInputProcessor(screenStage);
		screenStage.addListener(new InputListener() {
			@Override
			public boolean keyDown (InputEvent event, int key) {
				if (key == Keys.F1)
					debugConsole.toggleVisible();
				return true;
			}
		});
		screenStage.addActor(debugConsole);
	}

	public void render () {
		screenStage.act();
		screenStage.draw();
	}

	public Stage getStage () {
		return screenStage;
	}

}

Fix UI Not Being Loaded


package pipe.actions.file;

import pipe.gui.ApplicationSettings;
import pipe.views.PipeApplicationView;

import java.awt.event.ActionEvent;

public class CreateAction extends FileAction {

    public CreateAction() {
        super("New", "Create a new Petri net", "ctrl N");
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        PipeApplicationView view = ApplicationSettings.getApplicationView();
        ApplicationSettings.getApplicationController().createNewTabFromFile(
                null, false);
    }
}

package pipe.actions.file;

import pipe.controllers.PipeApplicationController;
import pipe.gui.ApplicationSettings;
import pipe.views.PipeApplicationView;

import java.awt.event.ActionEvent;

public class CreateAction extends FileAction {

    public CreateAction() {
        super("New", "Create a new Petri net", "ctrl N");
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        PipeApplicationController controller = ApplicationSettings.getApplicationController();
        controller.createEmptyPetriNet();
    }
}

Fix bug when pressing new


package com.yahoo.config.provision;

/**
 * The possible types of nodes in the node repository
 *
 * @author bratseth
 */
public enum NodeType {

    /** A host of a set of (docker) tenant nodes */
    host,

    /** Nodes running the shared proxy layer */
    proxy,

    /** A node to be assigned to a tenant to run application workloads */
    tenant

}

package com.yahoo.config.provision;

/**
 * The possible types of nodes in the node repository
 *
 * @author bratseth
 */
public enum NodeType {

    /** A host of a set of (docker) tenant nodes */
    host,

    /** Nodes running the shared proxy layer */
    proxy,

    /** A node to be assigned to a tenant to run application workloads */
    tenant,

    /** A config server */
    config

}

Add node type for config server


package com.woorea.openstack.heat;

import com.woorea.openstack.base.client.HttpMethod;
import com.woorea.openstack.base.client.OpenStackClient;
import com.woorea.openstack.base.client.OpenStackRequest;
import com.woorea.openstack.heat.model.Resources;

/**
 * v1/{tenant_id}/stacks/{stack_name}/resources
 */
public class ResourcesResource {
    private final OpenStackClient client;

    public ResourcesResource(OpenStackClient client) {
        this.client = client;
    }

    public ListResources listResources(String name) {
        return new ListResources(name);
    }

    public List list(String name) {
        return new List(name);
    }

    /**
     * v1/{tenant_id}/stacks/{stack_name}/resources
     */
    public class ListResources extends OpenStackRequest<Resources> {
        public ListResources(String name) {
            super(client, HttpMethod.GET, "/stacks/" + name + "/resources", null, Resources.class);
        }
    }

    /**
     * v1/{tenant_id}/stacks/{stack_name}/{stack_id}/resources
     */
    public class List extends OpenStackRequest<String> {
        public List(String name) {
            super(client, HttpMethod.GET, "", null, String.class);
        }
    }

}

package com.woorea.openstack.heat;

import com.woorea.openstack.base.client.HttpMethod;
import com.woorea.openstack.base.client.OpenStackClient;
import com.woorea.openstack.base.client.OpenStackRequest;
import com.woorea.openstack.heat.model.Resources;

/**
 * v1/{tenant_id}/stacks/{stack_name}/resources
 */
public class ResourcesResource {
    private final OpenStackClient client;

    public ResourcesResource(OpenStackClient client) {
        this.client = client;
    }

    public ListResources listResources(String name) {
        return new ListResources(name);
    }

    /**
     * v1/{tenant_id}/stacks/{stack_name}/resources
     */
    public class ListResources extends OpenStackRequest<Resources> {
        public ListResources(String name) {
            super(client, HttpMethod.GET, "/stacks/" + name + "/resources", null, Resources.class);
        }
    }
}

Remove obsolete list resources functions


package com.bkp.minerva;

import android.app.Application;
import android.content.Context;
import com.karumi.dexter.Dexter;

/**
 * Custom Application class.
 */
public class Minerva extends Application {
    /**
     * Static instance to (CAREFULLY) allow getting Application Context anywhere.
     */
    private static Minerva instance;

    @Override
    public void onCreate() {
        super.onCreate();
        // Stash application context.
        instance = this;
        // Init Dexter.
        Dexter.initialize(this);
    }

    /**
     * Get the application context. DO NOT use the context returned by this method in methods which affect the UI (such
     * as when inflating a layout, for example).
     * @return Application context.
     */
    public static Context getAppCtx() {
        return instance.getApplicationContext();
    }

}

package com.bkp.minerva;

import android.app.Application;
import android.content.Context;
import com.karumi.dexter.Dexter;
import io.realm.Realm;
import io.realm.RealmConfiguration;

/**
 * Custom Application class.
 */
public class Minerva extends Application {
    /**
     * Static instance to (CAREFULLY) allow getting Application Context anywhere.
     */
    private static Minerva instance;

    @Override
    public void onCreate() {
        super.onCreate();
        // Stash application context.
        instance = this;
        // Init Dexter.
        Dexter.initialize(this);
        // Set up Realm.
        setupRealm();
    }

    /**
     * Set up Realm's default configuration.
     */
    private void setupRealm() {
        RealmConfiguration config = new RealmConfiguration.Builder(this)
                .name("minerva.realm")
                .schemaVersion(0)
                .build();
        Realm.setDefaultConfiguration(config);
    }

    /**
     * Get the application context. DO NOT use the context returned by this method in methods which affect the UI (such
     * as when inflating a layout, for example).
     * @return Application context.
     */
    public static Context getAppCtx() {
        return instance.getApplicationContext();
    }
}

Set a default realm config


/*-------------------------------------------------------------------------
*
* Copyright (c) 2004-2005, PostgreSQL Global Development Group
*
* IDENTIFICATION
*   $PostgreSQL: pgjdbc/org/postgresql/util/PSQLDriverVersion.java,v 1.21 2006/12/01 12:06:21 jurka Exp $
*
*-------------------------------------------------------------------------
*/
package org.postgresql.util;

import org.postgresql.Driver;

/**
 * This class holds the current build number and a utility program to print
 * it and the file it came from.  The primary purpose of this is to keep
 * from filling the cvs history of Driver.java.in with commits simply
 * changing the build number.  The utility program can also be helpful for
 * people to determine what version they really have and resolve problems
 * with old and unknown versions located somewhere in the classpath.
 */
public class PSQLDriverVersion {

    public static int buildNumber = 600;

    public static void main(String args[]) {
        java.net.URL url = Driver.class.getResource("/org/postgresql/Driver.class");
        System.out.println(Driver.getVersion());
        System.out.println("Found in: " + url);
    }

}

/*-------------------------------------------------------------------------
*
* Copyright (c) 2004-2005, PostgreSQL Global Development Group
*
* IDENTIFICATION
*   $PostgreSQL: pgjdbc/org/postgresql/util/PSQLDriverVersion.java,v 1.22 2007/07/31 06:05:43 jurka Exp $
*
*-------------------------------------------------------------------------
*/
package org.postgresql.util;

import org.postgresql.Driver;

/**
 * This class holds the current build number and a utility program to print
 * it and the file it came from.  The primary purpose of this is to keep
 * from filling the cvs history of Driver.java.in with commits simply
 * changing the build number.  The utility program can also be helpful for
 * people to determine what version they really have and resolve problems
 * with old and unknown versions located somewhere in the classpath.
 */
public class PSQLDriverVersion {

    public final static int buildNumber = 601;

    public static void main(String args[]) {
        java.net.URL url = Driver.class.getResource("/org/postgresql/Driver.class");
        System.out.println(Driver.getVersion());
        System.out.println("Found in: " + url);
    }

}

Prepare for release for 8.3dev-601.


package com.bitgrind.android;

import java.util.Arrays;

import jsqlite.Callback;
import jsqlite.Exception;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;

public class SpatialiteTestActivity extends Activity {

  private static final String TAG = SpatialiteTestActivity.class.getSimpleName();

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

    jsqlite.Database db = new jsqlite.Database();
    try {

      db.open(Environment.getExternalStorageDirectory() + "/spatialite-test.db",
          jsqlite.Constants.SQLITE_OPEN_CREATE);
      Callback cb = new Callback() {
        @Override
        public void columns(String[] coldata) {
          Log.v(TAG, "Columns: " + Arrays.toString(coldata));
        }

        @Override
        public void types(String[] types) {
          Log.v(TAG, "Types: " + Arrays.toString(types));
        }

        @Override
        public boolean newrow(String[] rowdata) {
          Log.v(TAG, "Row: " + Arrays.toString(rowdata));

          // Careful (from parent javadoc):
          // "If true is returned the running SQLite query is aborted."
          return false;
        }
      };
      db.exec("SELECT spatialite_version();", cb);
    } catch (Exception e) {
      Log.e(TAG, "Exception caught", e);
    }
  }
}

package com.bitgrind.android;

import java.util.Arrays;

import jsqlite.Callback;
import jsqlite.Exception;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;

public class SpatialiteTestActivity extends Activity {

  private static final String TAG = SpatialiteTestActivity.class.getName();
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    jsqlite.Database db = new jsqlite.Database();
    try {
      db.open(Environment.getExternalStorageDirectory() + "/spatialite_test.db",
          jsqlite.Constants.SQLITE_OPEN_READONLY);
      Callback cb = new Callback() {
        @Override
        public void columns(String[] coldata) {
          Log.v(TAG, "Columns: " + Arrays.toString(coldata));
        }

        @Override
        public void types(String[] types) {
          Log.v(TAG, "Types: " + Arrays.toString(types));
        }

        @Override
        public boolean newrow(String[] rowdata) {
          Log.v(TAG, "Row: " + Arrays.toString(rowdata));

          // Careful (from parent javadoc):
          // "If true is returned the running SQLite query is aborted."
          return false;
        }
      };
      db.exec("SELECT name, peoples, AsText(GaiaGeometry) from Towns where peoples > 350000 order by peoples DESC;", cb);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

Test Activity: Restore the full test with sample db since it causes SIGSEGV :-(


/*
 * Copyright 2015 Martijn van der Woud - The Crimson Cricket Internet Services
 *
 *    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.crimsoncricket.asserts;

import java.util.Collection;

public class Assert {

    public static void assertStateNotNull(Object anObject, String message) {
        if (anObject == null)
            throw new IllegalStateException(message);
    }

    public static void assertArgumentNotNull(Object anArgument, String message) {
        if (anArgument == null)
            throw new IllegalArgumentException(message);
    }

    public static void assertStringArgumentNotEmpty(String anArgument, String message) {
        if (anArgument.isEmpty())
            throw new IllegalArgumentException(message);
    }

    public static void assertArgumentCollectionNotContainsNull(Collection<?> anArgument, String message) {
        if (anArgument.stream().anyMatch(element -> element == null))
            throw new IllegalArgumentException(message);

    }

}

/*
 * Copyright 2015 Martijn van der Woud - The Crimson Cricket Internet Services
 *
 *    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.crimsoncricket.asserts;

import java.util.Collection;

public class Assert {

    public static void assertStateNotNull(Object anObject, String message) {
        if (anObject == null)
            throw new IllegalStateException(message);
    }

    public static void assertArgumentNotNull(Object anArgument, String message) {
        if (anArgument == null)
            throw new IllegalArgumentException(message);
    }

    public static void assertStringArgumentNotEmpty(String anArgument, String message) {
        if (anArgument.trim().isEmpty())
            throw new IllegalArgumentException(message);
    }

    public static void assertArgumentCollectionNotContainsNull(Collection<?> anArgument, String message) {
        if (anArgument.stream().anyMatch(element -> element == null))
            throw new IllegalArgumentException(message);

    }

}

Trim value before checking if string is empty


// Copyright 2014, Kevin Ko <kevin@faveset.com>

package com.faveset.khttp;

import java.nio.ByteBuffer;

/**
 * Note that all implementations may be initialized statically and thus
 * should be stateless.
 */
interface StateHandler {
    /**
     * Performs a step of the state machine when reading new data from the
     * connection.
     *
     * @param buf holds unread data from the connection.
     *
     * @return true if the state is complete.  False if more data is needed
     * in buf to proceed.
     */
    boolean handleState(NonBlockingConnection conn, ByteBuffer buf, HandlerState state) throws InvalidRequestException;
}

// Copyright 2014, Kevin Ko <kevin@faveset.com>

package com.faveset.khttp;

import java.nio.ByteBuffer;

/**
 * Note that all implementations may be initialized statically and thus
 * should be stateless.
 */
interface StateHandler {
    /**
     * Performs a step of the state machine when reading new data from the
     * connection.
     *
     * @param buf holds unread data from the connection.
     *
     * @return true if the state is complete.  False if more data is needed
     * in buf to proceed.
     *
     * @throws InvalidRequestException
     */
    boolean handleState(NonBlockingConnection conn, ByteBuffer buf, HandlerState state) throws InvalidRequestException;
}

Update comments for thrown exceptions.


package gsg.infrastructure;

import gsg.threads.IJob;
import gsg.threads.JobRunner;
import gsg.threads.JobRunnerConfiguration;

/**
 * @author zkejid@gmail.com
 *         Created: 23.07.15 9:37
 */
public class Utils {

	public static String getMessage(String line) {
		final int i = line.indexOf(" ");
		if (i > -1 && i < line.length()) {
			return line.substring(i+1, line.length());
		}
		else {
			return null;
		}
	}

	public static String getKey(String line) {
		final int i = line.indexOf(" ");
		if (i > -1) {
			return line.substring(0, i);
		}
		else {
			return null;
		}
	}

	public static JobRunner runLoop(IJob job) {
		final JobRunnerConfiguration configuration = new JobRunnerConfiguration();
		final JobRunner runner = new JobRunner(configuration, job);
		runner.start();
		return runner;
	}

	public static void runLoopAndJoin(IJob job) {
		final JobRunner runner = runLoop(job);
		try {
			runner.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}

package gsg.infrastructure;

import gsg.threads.IJob;
import gsg.threads.JobRunner;
import gsg.threads.JobRunnerConfiguration;

/**
 * @author zkejid@gmail.com
 *         Created: 23.07.15 9:37
 */
public class Utils {

	public static String getMessage(String line) {
		final int i = line.indexOf(" ");
		if (i > -1 && i < line.length()) {
			return line.substring(i+1, line.length());
		}
		else {
			return null;
		}
	}

	public static String getKey(String line) {
		final int i = line.indexOf(" ");
		if (i > -1) {
			return line.substring(0, i);
		}
		else {
			return null;
		}
	}

	public static JobRunner runLoop(IJob job) {
		final JobRunnerConfiguration configuration = new JobRunnerConfiguration();
		configuration.setDoLog(false);
		final JobRunner runner = new JobRunner(configuration, job);
		runner.start();
		return runner;
	}

	public static void runLoopAndJoin(IJob job) {
		final JobRunner runner = runLoop(job);
		try {
			runner.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}

Set default configuration value of JobRunner.doLog to false


package guitests;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class ClearCommandTest extends TaskManagerGuiTest {

    @Test
    public void clear() {

        //verify a non-empty list can be cleared
        //TO BE UPDATED assertTrue(taskListPanel.isListMatching(td.getTypicalTasks()));
        assertClearCommandSuccess();

        //verify other commands can work after a clear command
        commandBox.runCommand(td.gym.getAddCommand());
        assertTrue(taskListPanel.isListMatching(td.gym));
        commandBox.runCommand("delete 1");
        assertListSize(0);

        //verify clear command works when the list is empty
        assertClearCommandSuccess();
    }

    private void assertClearCommandSuccess() {
        commandBox.runCommand("clear");
        assertListSize(0);
        assertResultMessage("Dueue has been cleared!");
    }
}

package guitests;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class ClearCommandTest extends TaskManagerGuiTest {

    @Test
    public void clear() {

        //verify a non-empty list can be cleared
        //TO BE UPDATED assertTrue(taskListPanel.isListMatching(td.getTypicalTasks()));
        assertClearCommandSuccess();

        //verify other commands can work after a clear command
        commandBox.runCommand(td.gym.getAddCommand());
        //TODO: remove nullpointerexception
        //assertTrue(taskListPanel.isListMatching(td.gym));
        commandBox.runCommand("delete 1");
        assertListSize(0);

        //verify clear command works when the list is empty
        assertClearCommandSuccess();
    }

    private void assertClearCommandSuccess() {
        commandBox.runCommand("clear");
        assertListSize(0);
        assertResultMessage("Dueue has been cleared!");
    }
}

Comment out failing test in ClearCommand


package net.katsuster.strview.ui;

import java.awt.HeadlessException;

import javax.swing.*;

import net.katsuster.strview.io.*;
import net.katsuster.strview.gui.*;

/**
 * メインクラス。
 */
public class Main {
    protected Main() {
        //do nothing
    }

    public static void main(String[] args) {
        FileDropWindow w = null;

        try {
            //Look and Feel をシステム標準に変更する
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception ex) {
                ex.printStackTrace();
                return;
            }

            //結果表示用のフレームを作成する
            w = new FileDropWindow();
            w.setTitle("bined");
            w.setSize(300, 100);
            w.setVisible(true);
        } catch (HeadlessException ex) {

        }
    }
}

package net.katsuster.strview.ui;

import java.util.*;
import java.io.*;
import java.awt.HeadlessException;

import javax.swing.*;

import net.katsuster.strview.io.*;
import net.katsuster.strview.gui.*;
import net.katsuster.strview.media.ts.*;

/**
 * メインクラス。
 */
public class Main {
    protected Main() {
        //do nothing
    }

    public static void main(String[] args) {
        FileDropWindow w = null;

        if (args.length > 0) {
            String fname = args[0];
            List<File> flist = new ArrayList<File>();

            flist.add(new File(fname));

            LargeBitList blist = new ByteToBitList(new FileByteList(fname));
            TSPacketList tslist = new TSPacketList(blist);

            //tslist.count();

            for (TSPacket a : tslist) {
                System.out.println(a);
            }
        }

        try {
            //Look and Feel をシステム標準に変更する
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception ex) {
                ex.printStackTrace();
                return;
            }

            //結果表示用のフレームを作成する
            w = new FileDropWindow();
            w.setTitle("bined");
            w.setSize(300, 100);
            w.setVisible(true);
        } catch (HeadlessException ex) {

        }
    }
}

Add tentative test codes for MPEG2-TS packet parser.


package starpunk.screens;

import com.badlogic.gdx.Screen;
import starpunk.StarPunkGame;

public abstract class BaseScreen
  implements Screen
{
  private final StarPunkGame _game;

  protected BaseScreen( final StarPunkGame game )
  {
    _game = game;
  }

  protected final StarPunkGame getGame()
  {
    return _game;
  }

  public abstract void update( float delta );

  public abstract void draw( float delta );

  @Override
  public void render( final float delta )
  {
    update( delta );
    draw( delta );
  }

  @Override
  public void resize( final int width, final int height )
  {
  }

  @Override
  public void show()
  {
  }

  @Override
  public void hide()
  {
  }

  @Override
  public void pause()
  {
  }

  @Override
  public void resume()
  {
  }

  @Override
  public void dispose()
  {
  }
}

package starpunk.screens;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import starpunk.StarPunkGame;

public abstract class BaseScreen
  implements Screen
{
  private final StarPunkGame _game;

  protected BaseScreen( final StarPunkGame game )
  {
    _game = game;
  }

  protected final StarPunkGame getGame()
  {
    return _game;
  }

  public abstract void update( float delta );

  public abstract void draw( float delta );

  @Override
  public void render( final float delta )
  {
    update( delta );
    draw( delta );
  }

  @Override
  public void resize( final int width, final int height )
  {
    log( "Resizing screen to: " + width + " x " + height );
  }

  @Override
  public void show()
  {
    log( "Showing screen" );
  }

  @Override
  public void hide()
  {
    log( "Hiding screen" );
  }

  @Override
  public void pause()
  {
    log( "Pausing screen" );
  }

  @Override
  public void resume()
  {
    log( "Resuming screen" );
  }

  @Override
  public void dispose()
  {
    log( "Disposing screen" );
  }

  private void log( final String message )
  {
    Gdx.app.log( getClass().getSimpleName(), message );
  }
}

Introduce some logging in screens to aid in the debugging


/**
*    Copyright 2012, Big Switch Networks, Inc.
*    Originally created by David Erickson, Stanford University
*
*    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 net.floodlightcontroller.devicemanager.web;

import org.restlet.Context;
import org.restlet.Restlet;
import org.restlet.routing.Router;

import net.floodlightcontroller.restserver.RestletRoutable;

/**
 * Routable for device rest api
 */
public class DeviceRoutable implements RestletRoutable {

    @Override
    public String basePath() {
        return "/wm/device";
    }

    @Override
    public Restlet getRestlet(Context context) {
        Router router = new Router(context);
        router.attach("/json", DeviceResource.class);
        router.attach("/debug", DeviceEntityResource.class);
        return router;
    }

}

/**
*    Copyright 2012, Big Switch Networks, Inc.
*    Originally created by David Erickson, Stanford University
*
*    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 net.floodlightcontroller.devicemanager.web;

import org.restlet.Context;
import org.restlet.Restlet;
import org.restlet.routing.Router;

import net.floodlightcontroller.restserver.RestletRoutable;

/**
 * Routable for device rest api
 */
public class DeviceRoutable implements RestletRoutable {

    @Override
    public String basePath() {
        return "/wm/device";
    }

    @Override
    public Restlet getRestlet(Context context) {
        Router router = new Router(context);
        router.attach("/all/json", DeviceResource.class);
        router.attach("/", DeviceResource.class);
        router.attach("/debug", DeviceEntityResource.class);
        return router;
    }

}

Use /wm/device/all/json for all devices and /*** where *** is a filter by mac, vlan, ip, etc


package org.opennms.netmgt.dao.db;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

public class PopulatedTemporaryDatabaseTestCase extends
        TemporaryDatabaseTestCase {

    private InstallerDb installerDb;

    private ByteArrayOutputStream m_outputStream;

    protected void setUp() throws Exception {
        super.setUp();

        initializeDatabase();
    }

    protected void initializeDatabase() throws Exception {
        if (!isEnabled()) {
            return;
        }

        installerDb = new InstallerDb();

        // Create a ByteArrayOutputSteam to effectively throw away output.
        resetOutputStream();
        installerDb.setDatabaseName(getTestDatabase());
        installerDb.setDataSource(getDataSource());

        installerDb.setCreateSqlLocation(
            "../opennms-daemon/src/main/filtered/etc/create.sql");

        installerDb.setStoredProcedureDirectory(
            "../opennms-daemon/src/main/filtered/etc");

        //installerDb.setDebug(true);

        installerDb.readTables();

        installerDb.createSequences();
        installerDb.updatePlPgsql();
        installerDb.addStoredProcedures();

        installerDb.createTables();

        installerDb.closeConnection();
    }

    public ByteArrayOutputStream getOutputStream() {
        return m_outputStream;
    }

    public void resetOutputStream() {
        m_outputStream = new ByteArrayOutputStream();
        installerDb.setOutputStream(new PrintStream(m_outputStream));
    }
}

package org.opennms.netmgt.dao.db;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

public class PopulatedTemporaryDatabaseTestCase extends
        TemporaryDatabaseTestCase {

    private InstallerDb m_installerDb;

    private ByteArrayOutputStream m_outputStream;

    protected void setUp() throws Exception {
        super.setUp();

        initializeDatabase();
    }

    protected void initializeDatabase() throws Exception {
        if (!isEnabled()) {
            return;
        }

        m_installerDb = new InstallerDb();

        // Create a ByteArrayOutputSteam to effectively throw away output.
        resetOutputStream();
        m_installerDb.setDatabaseName(getTestDatabase());
        m_installerDb.setDataSource(getDataSource());

        m_installerDb.setCreateSqlLocation(
            "../opennms-daemon/src/main/filtered/etc/create.sql");

        m_installerDb.setStoredProcedureDirectory(
            "../opennms-daemon/src/main/filtered/etc");

        //installerDb.setDebug(true);

        m_installerDb.readTables();

        m_installerDb.createSequences();
        m_installerDb.updatePlPgsql();
        m_installerDb.addStoredProcedures();

        m_installerDb.createTables();

        m_installerDb.closeConnection();
    }

    public ByteArrayOutputStream getOutputStream() {
        return m_outputStream;
    }

    public void resetOutputStream() {
        m_outputStream = new ByteArrayOutputStream();
        m_installerDb.setOutputStream(new PrintStream(m_outputStream));
    }
}

Fix the name for the installerDb field to match our conventions.


/**
 *  Copyright 2015 Peter Nerg
 *
 *  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 simplepool;

import org.junit.Test;

import simplepool.Constants.PoolMode;
/**
 * Test the class {@link PoolImpl}
 * @author Peter Nerg
 */
public class TestPoolImpl extends BaseAssert {

	private final PoolImpl<PoolableObject> pool = new PoolImpl<>(() -> new PoolableObject(), 2, po -> true, po -> {}, PoolMode.FIFO);

	@Test
	public void return_nullInstance() {
		pool.returnInstance(null);
	}

}

/**
 *  Copyright 2015 Peter Nerg
 *
 *  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 simplepool;

import org.junit.Test;

import javascalautils.Try;
import simplepool.Constants.PoolMode;
/**
 * Test the class {@link PoolImpl}
 * @author Peter Nerg
 */
public class TestPoolImpl extends BaseAssert {

	private final PoolImpl<PoolableObject> pool = new PoolImpl<>(() -> new PoolableObject(), 2, po -> true, po -> {}, PoolMode.FIFO);

	@Test
	public void getInstance() throws Throwable {
		Try<PoolableObject> instance = pool.getInstance();
		assertTrue(instance.isSuccess());
		assertTrue(instance.get() instanceof PoolableObject);
	}

	@Test
	public void return_nullInstance() {
		pool.returnInstance(null);
	}

}

Test to get single instance in PoolImpl


/*
 *  Copyright (c) 2012 Malhar, Inc.
 *  All Rights Reserved.
 */
package com.malhartech.stream.kafka;

import com.malhartech.dag.Sink;
import com.malhartech.dag.Stream;
import com.malhartech.dag.StreamConfiguration;
import com.malhartech.dag.StreamContext;
import com.malhartech.dag.Tuple;
import kafka.javaapi.producer.Producer;

/**
 *
 * @author Chetan Narsude <chetan@malhar-inc.com>
 */
public class KafkaOutputStream
  implements Stream, Sink
{
  @Override
  public void setup(StreamConfiguration config)
  {
    Producer producer;

    throw new UnsupportedOperationException("Not supported yet.");
  }

  @Override
  public void setContext(StreamContext context)
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }

  @Override
  public void teardown()
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }

  @Override
  public void doSomething(Tuple t)
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }

  @Override
  public StreamContext getContext()
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }

  public boolean hasFinished()
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }

  public void activate()
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }
}

/*
 *  Copyright (c) 2012 Malhar, Inc.
 *  All Rights Reserved.
 */
package com.malhartech.stream.kafka;

import com.malhartech.api.Sink;
import com.malhartech.dag.Stream;
import com.malhartech.dag.StreamConfiguration;
import com.malhartech.dag.StreamContext;
import com.malhartech.dag.Tuple;
import kafka.javaapi.producer.Producer;

/**
 *
 * @author Chetan Narsude <chetan@malhar-inc.com>
 */
public class KafkaOutputStream
  implements Stream, Sink
{
  @Override
  public void setup(StreamConfiguration config)
  {
    Producer producer;

    throw new UnsupportedOperationException("Not supported yet.");
  }

  @Override
  public void setContext(StreamContext context)
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }

  @Override
  public void teardown()
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }

  @Override
  public void doSomething(Tuple t)
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }

  @Override
  public StreamContext getContext()
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }

  public boolean hasFinished()
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }

  public void activate()
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }
}

Integrate new packages. The code does not compile.


package net.towerwarz;

import net.towerwarz.exception.UnknownObjectException;

import java.util.Arrays;

/**
 * TowerWarZ
 * Created by xiurobert on 2/14/2016.
 */

/**
 * This file is the init file and contains functions to set and retrieve certain game properties
 */
public class GameInstance {
    private int WaveNumber;
    private String difficulty;
    private String MapName;

    private String[] maps = {
            "GrassLands",
            "HellWorld",
            "IceLand",
            "DarkForest"

    };
    private String[] difficulties = {
            "Easy",
            "Normal",
            "Hard",
            "Sparta"
    };

    public GameInstance(String difficulty, int mapName){
        //starting game
        this.difficulty = difficulty;
        this.MapName = mapName;
        this.WaveNumber = 1;

        //load window
        //draw

    }

    public String setDifficulty(String diff) throws UnknownObjectException {
        if (Arrays.asList(difficulties).contains(diff)) { // Check if the difficulty is valid
            difficulty = diff; // Set difficulty
        } else {
            throw new UnknownObjectException("Invalid difficulty");
        }
        return difficulty;
    }

    public String getDifficulty() {
        return difficulty;
    }

    public String setMap(String map) throws UnknownObjectException {
        if (Arrays.asList(maps).contains(map)) {
            MapName = map;
        } else {
            throw new UnknownObjectException("Invalid map");
        }
        return MapName;
    }

    public String getMapName() {
        return MapName;
    }

    public int getWaveNumber() {
        return WaveNumber;
    }
}

package net.towerwarz;

import net.towerwarz.exception.UnknownObjectException;

import java.util.Arrays;

/**
 * TowerWarZ
 * Created by xiurobert on 2/14/2016.
 */

/**
 * This file is the init file and contains functions to set and retrieve certain game properties
 */
public class GameInstance {
    private int WaveNumber;
    private String difficulty;
    private String MapName;

    private String[] maps = {
            "GrassLands",
            "HellWorld",
            "IceLand",
            "DarkForest"

    };
    private String[] difficulties = {
            "Easy",
            "Normal",
            "Hard",
            "Sparta"
    };

    public String setDifficulty(String diff) throws UnknownObjectException {
        if (Arrays.asList(difficulties).contains(diff)) { // Check if the difficulty is valid
            difficulty = diff; // Set difficulty
        } else {
            throw new UnknownObjectException("Invalid difficulty");
        }
        return difficulty;
    }

    public String getDifficulty() {
        return difficulty;
    }

    public String setMap(String map) throws UnknownObjectException {
        if (Arrays.asList(maps).contains(map)) {
            MapName = map;
        } else {
            throw new UnknownObjectException("Invalid map");
        }
        return MapName;
    }

    public String getMapName() {
        return MapName;
    }

    public int getWaveNumber() {
        return WaveNumber;
    }
}

Revert "added constructor to gameInstance.java"


package com.cloudbees.plugins.deployer.casc;

import com.cloudbees.plugins.deployer.DeployNowColumn;
import hudson.model.View;
import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;

public class ConfigurationAsCodeTest {
    @Rule
    public JenkinsConfiguredWithCodeRule r = new JenkinsConfiguredWithCodeRule();

    @Test
    @ConfiguredWithCode("view-configuration.yml")
    public void shouldBeAbleToConfigureAView() throws Exception {
        final View view = r.jenkins.getView("view-with-deployNowColumn");
        Assert.assertNotNull(view);

        MatcherAssert.assertThat(view.getColumns(),
              Matchers.hasItem(Matchers.instanceOf(DeployNowColumn.class))
        );
    }
}

package com.cloudbees.plugins.deployer.casc;

import com.cloudbees.plugins.deployer.DeployNowColumn;
import hudson.model.View;
import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;

import java.util.stream.StreamSupport;

public class ConfigurationAsCodeTest {
    @Rule
    public JenkinsConfiguredWithCodeRule r = new JenkinsConfiguredWithCodeRule();

    @Test
    @ConfiguredWithCode("view-configuration.yml")
    public void shouldBeAbleToConfigureAView() throws Exception {
        final View view = r.jenkins.getView("view-with-deployNowColumn");
        Assert.assertNotNull(view);

        Assert.assertTrue(
            StreamSupport.stream(view.getColumns().spliterator(), false)
                  .anyMatch(
                        item -> item instanceof DeployNowColumn
                  )
        );
    }
}

Simplify test code for jcasc support


package gr.demokritos.iit.ydsapi.model;

import java.util.HashSet;
import java.util.Set;

/**
 * accepted component types.
 *
 * @author George K. <gkiom@iit.demokritos.gr>
 */
public enum ComponentType {

    LINE("line"), SCATTER("scatter"), PIE("pie"), BAR("bar"), TREE("tree"), MAP("map"), GRID("grid"), RESULT("result"), RESULTSET("resultset");
    private final String type;

    private ComponentType(String type) {
        this.type = type;
    }

    public String getDecl() {
        return type;
    }
    public static final Set<String> ACCEPTED = new HashSet();

    static {
        ACCEPTED.add(LINE.getDecl());
        ACCEPTED.add(SCATTER.getDecl());
        ACCEPTED.add(PIE.getDecl());
        ACCEPTED.add(BAR.getDecl());
        ACCEPTED.add(TREE.getDecl());
        ACCEPTED.add(MAP.getDecl());
        ACCEPTED.add(GRID.getDecl());
        ACCEPTED.add(RESULT.getDecl());
        ACCEPTED.add(RESULTSET.getDecl());
    }
}

package gr.demokritos.iit.ydsapi.model;

import java.util.HashSet;
import java.util.Set;

/**
 * accepted component types.
 *
 * @author George K. <gkiom@iit.demokritos.gr>
 */
public enum ComponentType {

    LINE("line"), SCATTER("scatter"), BUBBLE("bubble"), PIE("pie"), BAR("bar"), TREE("tree"), MAP("map"), GRID("grid"), RESULT("result"), RESULTSET("resultset");
    private final String type;

    private ComponentType(String type) {
        this.type = type;
    }

    public String getDecl() {
        return type;
    }
    public static final Set<String> ACCEPTED = new HashSet();

    static {
        ACCEPTED.add(LINE.getDecl());
        ACCEPTED.add(SCATTER.getDecl());
        ACCEPTED.add(BUBBLE.getDecl());
        ACCEPTED.add(PIE.getDecl());
        ACCEPTED.add(BAR.getDecl());
        ACCEPTED.add(TREE.getDecl());
        ACCEPTED.add(MAP.getDecl());
        ACCEPTED.add(GRID.getDecl());
        ACCEPTED.add(RESULT.getDecl());
        ACCEPTED.add(RESULTSET.getDecl());
    }
}

Add support for bubble charts in Backend Utilities


package com.tinkerpop.gremlin.structure.io.graphson;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;

import java.util.Optional;

/**
 * @author Stephen Mallette (http://stephen.genoprime.com)
 */
public class GraphSONObjectMapper extends ObjectMapper {
    public GraphSONObjectMapper() {
        this(null);
    }

    public GraphSONObjectMapper(final SimpleModule custom) {
        disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);

        // this provider toStrings all unknown classes and converts keys in Map objects that are Object to String.
        final DefaultSerializerProvider provider = new GraphSONSerializerProvider();
        provider.setDefaultKeySerializer(new GraphSONModule.GraphSONKeySerializer());
        setSerializerProvider(provider);

        registerModule(new GraphSONModule());
        Optional.ofNullable(custom).ifPresent(this::registerModule);

        // plugin external serialization modules
        findAndRegisterModules();
    }
}

package com.tinkerpop.gremlin.structure.io.graphson;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;

import java.util.Optional;

/**
 * @author Stephen Mallette (http://stephen.genoprime.com)
 */
public class GraphSONObjectMapper extends ObjectMapper {
    public GraphSONObjectMapper() {
        this(null, false);
    }

    public GraphSONObjectMapper(final SimpleModule custom) {
        this(custom, false);
    }

    public GraphSONObjectMapper(final SimpleModule custom, final boolean loadExternalModules) {
        disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);

        // this provider toStrings all unknown classes and converts keys in Map objects that are Object to String.
        final DefaultSerializerProvider provider = new GraphSONSerializerProvider();
        provider.setDefaultKeySerializer(new GraphSONModule.GraphSONKeySerializer());
        setSerializerProvider(provider);

        registerModule(new GraphSONModule());
        Optional.ofNullable(custom).ifPresent(this::registerModule);

        // plugin external serialization modules
        if (loadExternalModules)
            findAndRegisterModules();
    }
}

Configure dynamic serializer loader for GraphSON


package beaform.utilities;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class SystemTimeTest {

	@Test
	public void testDefaultTimeSource() {
		final long start = System.currentTimeMillis();
		final long tested = SystemTime.getAsLong();
		final long end = System.currentTimeMillis();

		assertBetween("The tested value is not between the given arguments", start, end, tested);
	}

	private void assertBetween(String message, long boundary1, long boundary2, long tested) {
		long upper, lower;

		if (boundary1 <= boundary2) {
			lower = boundary1;
			upper = boundary2;
		}
		else {
			lower = boundary2;
			upper = boundary1;
		}

		assertTrue(message, (lower <= tested) && (tested <= upper));
	}

}

package beaform.utilities;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class SystemTimeTest {

	@Test
	public void testDefaultTimeSource() {
		final long start = System.currentTimeMillis();
		final long tested = SystemTime.getAsLong();
		final long end = System.currentTimeMillis();

		assertTrue("The tested value is not between the given arguments", isBetween(start, end, tested));
	}

	private boolean isBetween(long boundary1, long boundary2, long tested) {
		long upper, lower;

		if (boundary1 <= boundary2) {
			lower = boundary1;
			upper = boundary2;
		}
		else {
			lower = boundary2;
			upper = boundary1;
		}

		return (lower <= tested) && (tested <= upper);
	}

}

Move the actual assertion to the test


/**
 * Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */

package com.opengamma.language.identifier;

import com.opengamma.language.convert.AbstractMappedConverter;
import com.opengamma.language.convert.TypeMap;
import com.opengamma.language.definition.JavaTypeInfo;

/**
 * Converts ExternalSchemeRank to/from an array of strings.
 */
public class ExternalSchemeRankConverter extends AbstractMappedConverter {

  private static final JavaTypeInfo<String[]> STRING_ARRAY = JavaTypeInfo.builder(String[].class).get();
  private static final JavaTypeInfo<ExternalSchemeRank> EXTERNAL_SCHEME_RANK = JavaTypeInfo.builder(ExternalSchemeRank.class).get();

  /**
   * Default instance.
   */
  public static final ExternalSchemeRankConverter INSTANCE = new ExternalSchemeRankConverter();

  protected ExternalSchemeRankConverter() {
    conversion(TypeMap.ZERO_LOSS, STRING_ARRAY, EXTERNAL_SCHEME_RANK, new Action<String[], ExternalSchemeRank>() {
      @Override
      protected ExternalSchemeRank convert(final String[] value) {
        return ExternalSchemeRank.ofStrings(value);
      }
    });
    conversion(TypeMap.MINOR_LOSS, EXTERNAL_SCHEME_RANK, STRING_ARRAY, new Action<ExternalSchemeRank, String[]>() {
      @Override
      protected String[] convert(final ExternalSchemeRank value) {
        return value.asStrings();
      }
    });
  }

}

/**
 * Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */

package com.opengamma.language.identifier;

import com.opengamma.language.convert.AbstractMappedConverter;
import com.opengamma.language.convert.TypeMap;
import com.opengamma.language.definition.JavaTypeInfo;

/**
 * Converts ExternalSchemeRank to/from an array of strings.
 */
public class ExternalSchemeRankConverter extends AbstractMappedConverter {

  private static final JavaTypeInfo<String[]> STRING_ARRAY = JavaTypeInfo.builder(String[].class).allowNull().get();
  private static final JavaTypeInfo<ExternalSchemeRank> EXTERNAL_SCHEME_RANK = JavaTypeInfo.builder(ExternalSchemeRank.class).allowNull().get();

  /**
   * Default instance.
   */
  public static final ExternalSchemeRankConverter INSTANCE = new ExternalSchemeRankConverter();

  protected ExternalSchemeRankConverter() {
    conversion(TypeMap.ZERO_LOSS, STRING_ARRAY, EXTERNAL_SCHEME_RANK, new Action<String[], ExternalSchemeRank>() {
      @Override
      protected ExternalSchemeRank convert(final String[] value) {
        return ExternalSchemeRank.ofStrings(value);
      }
    });
    conversion(TypeMap.MINOR_LOSS, EXTERNAL_SCHEME_RANK, STRING_ARRAY, new Action<ExternalSchemeRank, String[]>() {
      @Override
      protected String[] convert(final ExternalSchemeRank value) {
        return value.asStrings();
      }
    });
  }

}

Allow NULL scheme rank conversions.


package entities;

import java.awt.Graphics2D;
import java.util.Random;

public class Entity {
  public static Random r;
  protected int cellX, cellY;

  public Entity() {
    this.r = new Random();
  }

  public Entity(int cellX, int cellY) {
    this.r = new Random();
    this.cellX = cellX;
    this.cellY = cellY;
  }

  public void setPosition(int cellX, int cellY) {
    this.cellX = cellX;
    this.cellY = cellY;
  }

  public void update() {}

  public void update(boolean[] keys) {}

  public void draw(Graphics2D g2d) {}

  public boolean collide(Entity entity) {
    if (entity.cellX == this.cellX && entity.cellY == this.cellY)
      return true;
    return false;
  }
}

package entities;

import java.awt.Graphics2D;
import java.util.Random;

public class Entity {
  public Random r;
  protected int cellX, cellY;

  public Entity() {
    this.r = new Random();
  }

  public Entity(int cellX, int cellY) {
    this.r = new Random();
    this.cellX = cellX;
    this.cellY = cellY;
  }

  public void setPosition(int cellX, int cellY) {
    this.cellX = cellX;
    this.cellY = cellY;
  }

  public void update() {}

  public void update(boolean[] keys) {}

  public void draw(Graphics2D g2d) {}

  public boolean collide(Entity entity) {
    if (entity.cellX == this.cellX && entity.cellY == this.cellY)
      return true;
    return false;
  }
}

Remove static modifier of r


package org.bricolages.streaming;

import lombok.Getter;
import lombok.Setter;

import org.bricolages.streaming.preflight.domains.DomainDefaultValues;
import org.bricolages.streaming.s3.ObjectMapper;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

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

@Component
@ConfigurationProperties(prefix = "bricolage")
public class Config {
    @Getter
    private final EventQueue eventQueue = new EventQueue();
    @Getter
    private final LogQueue logQueue = new LogQueue();
    @Getter
    private List<ObjectMapper.Entry> mappings = new ArrayList<>();

    @Setter
    static class EventQueue {
        String url;
        int visibilityTimeout;
        int maxNumberOfMessages;
        int waitTimeSeconds;
    }

    @Setter
    static class LogQueue {
        String url;
    }

    // preflight
    @Getter
    @Setter
    private String srcDs;
    @Getter
    @Setter
    private String destDs;
    @Getter
    @Setter
    private DomainDefaultValues defaults;
}

package org.bricolages.streaming;

import lombok.Getter;
import lombok.Setter;

import org.bricolages.streaming.s3.ObjectMapper;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

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

@Component
@ConfigurationProperties(prefix = "bricolage")
public class Config {
    @Getter
    private final EventQueue eventQueue = new EventQueue();
    @Getter
    private final LogQueue logQueue = new LogQueue();
    @Getter
    private List<ObjectMapper.Entry> mappings = new ArrayList<>();

    @Setter
    static class EventQueue {
        String url;
        int visibilityTimeout;
        int maxNumberOfMessages;
        int waitTimeSeconds;
    }

    @Setter
    static class LogQueue {
        String url;
    }

    // preflight
    @Getter
    @Setter
    private String srcDs;
    @Getter
    @Setter
    private String destDs;
}

Delete useless property (I do not clear why it was)


package seedu.address.ui;

import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import seedu.address.model.task.ReadOnlyTask;

public class TaskCard extends UiPart{

    private static final String FXML = "TaskListCard.fxml";

    @FXML
    private HBox cardPane;
    @FXML
    private Label detail;
    @FXML
    private Label id;
    @FXML
    private Label dbd;
    @FXML
    private Label dbt;
    @FXML
    private Label priority;
    @FXML
    private Label tags;

    private ReadOnlyTask task;
    private int displayedIndex;

    public TaskCard(){

    }

    public static TaskCard load(ReadOnlyTask task, int displayedIndex){
        TaskCard card = new TaskCard();
        card.task = task;
        card.displayedIndex = displayedIndex;
        return UiPartLoader.loadUiPart(card);
    }

    @FXML
    public void initialize() {
        detail.setText(task.getDetail().details);
        id.setText(displayedIndex + ". ");
        dbd.setText(task.getDueByDate().getFriendlyString());
        dbt.setText(task.getDueByTime().getFriendlyString());
        priority.setText(task.getPriority().value);
        tags.setText(task.tagsString());
    }

    public HBox getLayout() {
        return cardPane;
    }

    @Override
    public void setNode(Node node) {
        cardPane = (HBox)node;
    }

    @Override
    public String getFxmlPath() {
        return FXML;
    }
}

package seedu.address.ui;

import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import seedu.address.model.task.ReadOnlyTask;

public class TaskCard extends UiPart{

    private static final String FXML = "TaskListCard.fxml";

    @FXML
    private HBox cardPane;
    @FXML
    private Label detail;
    @FXML
    private Label id;
    @FXML
    private Label dbd;
    @FXML
    private Label dbt;
    @FXML
    private Label priority;
    @FXML
    private Label tags;

    private ReadOnlyTask task;
    private int displayedIndex;

    public TaskCard(){

    }

    public static TaskCard load(ReadOnlyTask task, int displayedIndex){
        TaskCard card = new TaskCard();
        card.task = task;
        card.displayedIndex = displayedIndex;
        return UiPartLoader.loadUiPart(card);
    }

    @FXML
    public void initialize() {
        detail.setText(task.getDetail().details);
        id.setText(displayedIndex + ". ");
        dbd.setText(task.getDueByDate().getFriendlyString());
        dbt.setText(task.getDueByTime().getFriendlyString());
        priority.setText(task.getPriority().value);
        tags.setText(task.tagsString());
        tags.setTextFill(Color.GOLD);
    }

    public HBox getLayout() {
        return cardPane;
    }

    @Override
    public void setNode(Node node) {
        cardPane = (HBox)node;
    }

    @Override
    public String getFxmlPath() {
        return FXML;
    }
}

Include task fields into taskcard - index,task,tag,due,priority


/*
 * Copyright (C) 2014 Pedro Vicente Gómez Sánchez.
 *
 * 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.github.pedrovgs.problem38;

/**
 * Given a binary tree, can you write a method to calculate every path to every leaf in the tree.
 *
 * @author Pedro Vicente Gómez Sánchez.
 */
public class PathToEveryLeaf {
}

/*
 * Copyright (C) 2014 Pedro Vicente Gómez Sánchez.
 *
 * 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.github.pedrovgs.problem38;

import com.github.pedrovgs.binarytree.BinaryNode;
import java.util.LinkedList;
import java.util.List;

/**
 * Given a binary tree, can you write a method to calculate every path to every leaf in the tree.
 *
 * @author Pedro Vicente Gómez Sánchez.
 */
public class PathToEveryLeaf {

  /**
   * Recursive algorithm to solve this problem. The complexity order of this algorithm is O(N)
   * where N is the number of elements in the array in time and space terms.
   */
  public List<List<BinaryNode>> calculate(BinaryNode<Integer> root) {
    if (root == null) {
      throw new IllegalArgumentException("You can't pass a null instance of BinaryNode");
    }
    return calculatePathToLeafs(root, new LinkedList<BinaryNode>());
  }

  private static List<List<BinaryNode>> calculatePathToLeafs(BinaryNode<Integer> root,
      List<BinaryNode> path) {
    List<List<BinaryNode>> paths = new LinkedList<List<BinaryNode>>();
    if (root == null) {
      return paths;
    } else if (root.getLeft() == null && root.getRight() == null) {
      path.add(root);
      paths.add(path);
      return paths;
    } else {
      path.add(root);
      paths.addAll(calculatePathToLeafs(root.getLeft(), new LinkedList<BinaryNode>(path)));
      paths.addAll(calculatePathToLeafs(root.getRight(), new LinkedList<BinaryNode>(path)));
      return paths;
    }
  }
}

Add recursive solution to problem 38


/*
 * Copyright 2015 Google 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 com.google.j2cl.ast;

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

import com.google.j2cl.ast.annotations.Visitable;
import com.google.j2cl.ast.processors.common.Processor;
import com.google.j2cl.common.SourcePosition;

/** A base class for Statement. */
@Visitable
public abstract class Statement extends Node implements HasSourcePosition, Cloneable<Statement> {
  // unknown by default.
  private SourcePosition sourcePosition;

  public Statement(SourcePosition sourcePosition) {
    setSourcePosition(sourcePosition);
  }

  @Override
  public SourcePosition getSourcePosition() {
    return sourcePosition;
  }

  public void setSourcePosition(SourcePosition sourcePosition) {
    this.sourcePosition = checkNotNull(sourcePosition);
  }

  @Override
  public abstract Statement clone();

  @Override
  public Node accept(Processor processor) {
    return Visitor_Statement.visit(processor, this);
  }
}

/*
 * Copyright 2015 Google 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 com.google.j2cl.ast;

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

import com.google.j2cl.ast.annotations.Visitable;
import com.google.j2cl.ast.processors.common.Processor;
import com.google.j2cl.common.SourcePosition;

/** A base class for Statement. */
@Visitable
public abstract class Statement extends Node implements HasSourcePosition, Cloneable<Statement> {
  // unknown by default.
  private SourcePosition sourcePosition;

  public Statement(SourcePosition sourcePosition) {
    setSourcePosition(sourcePosition);
  }

  @Override
  public final SourcePosition getSourcePosition() {
    return sourcePosition;
  }

  public final void setSourcePosition(SourcePosition sourcePosition) {
    this.sourcePosition = checkNotNull(sourcePosition);
  }

  @Override
  public abstract Statement clone();

  @Override
  public Node accept(Processor processor) {
    return Visitor_Statement.visit(processor, this);
  }
}

Make set/getSourcePosition final on Node.


/*
 * Copyright (c) 2015 Uber Technologies, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.uber.tchannel.schemes;

import io.netty.buffer.Unpooled;

public class DefaultRawRequestHandler implements RawRequestHandler {
    @Override
    public RawResponse handle(RawRequest request) {

        RawResponse response = new RawResponse(
                request.getId(),
                request.getTransportHeaders(),
                Unpooled.wrappedBuffer(new byte[]{0x00, 0x00}),
                Unpooled.wrappedBuffer(new byte[]{0x00, 0x00}),
                Unpooled.wrappedBuffer(new byte[]{0x00, 0x00})
        );

        return response;
    }
}

/*
 * Copyright (c) 2015 Uber Technologies, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.uber.tchannel.schemes;

public class DefaultRawRequestHandler implements RawRequestHandler {
    @Override
    public RawResponse handle(RawRequest request) {

        return new RawResponse(
                request.getId(),
                request.getTransportHeaders(),
                request.getArg1(),
                request.getArg2(),
                request.getArg3()
        );

    }
}

Make the DefaultRawRequest handler just echo back the request.


/*
 * Copyright 2020 The JSpecify Authors.
 *
 * 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.
 */

import org.jspecify.annotations.DefaultNonNull;
import org.jspecify.annotations.Nullable;
import org.jspecify.annotations.NullnessUnspecified;

@DefaultNonNull
class InstanceOfCheck {
  Object x0(Object o) {
    if (o instanceof Object) {
      return o;
    } else {
      return o;
    }
  }

  Object x1(@NullnessUnspecified Object o) {
    if (o instanceof Object) {
      return o;
    } else {
      // jspecify_nullness_not_enough_information
      return o;
    }
  }

  Object x2(@Nullable Object o) {
    if (o instanceof Object) {
      return o;
    } else {
      // jspecify_nullness_mismatch
      return o;
    }
  }
}

/*
 * Copyright 2020 The JSpecify Authors.
 *
 * 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.
 */

import org.jspecify.annotations.DefaultNonNull;
import org.jspecify.annotations.Nullable;
import org.jspecify.annotations.NullnessUnspecified;

@DefaultNonNull
class InstanceOfCheck {
  Object x0(Object o) {
    if (o instanceof Foo) {
      return o;
    } else {
      return o;
    }
  }

  Object x1(@NullnessUnspecified Object o) {
    if (o instanceof Foo) {
      return o;
    } else {
      // jspecify_nullness_not_enough_information
      return o;
    }
  }

  Object x2(@Nullable Object o) {
    if (o instanceof Foo) {
      return o;
    } else {
      // jspecify_nullness_mismatch
      return o;
    }
  }

  class Foo {}
}

Check `instanceof Foo` instead of `instanceof Object`.


package bj.pranie.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by Sebastian Sokolowski on 05.09.17.
 */
@Configuration
public class MvcConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/login").setViewName("index");
        registry.addViewController("/user/regulations").setViewName("/user/regulations");
    }

}

package bj.pranie.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by Sebastian Sokolowski on 05.09.17.
 */
@Configuration
public class MvcConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/login").setViewName("index");
        registry.addViewController("/user/regulations").setViewName("user/regulations");
    }

}

FIx missing regulations page issue


package com.arnaudpiroelle.muzei.marvel.source.command;

import android.content.Context;
import android.content.Intent;

import com.arnaudpiroelle.muzei.marvel.R;
import com.arnaudpiroelle.muzei.marvel.core.inject.Injector;
import com.google.android.apps.muzei.api.Artwork;
import com.google.android.apps.muzei.api.UserCommand;

import static com.arnaudpiroelle.muzei.marvel.core.inject.Injector.getContext;

public class PublishCommand extends UserCommand implements Command {

    public PublishCommand() {
        super(2, getContext().getString(R.string.command_publish));
    }

    @Override
    public void execute(Artwork artwork) {
        Context context = Injector.getContext();

        String detailUrl = artwork.getImageUri().toString();
        String artist = context.getResources().getString(R.string.marvel_copyright).trim();

        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");

        String appUrl = context.getString(R.string.app_url);
        String notifText = String.format(context.getString(R.string.share_template), artwork.getTitle().trim(), artist, detailUrl, appUrl);

        shareIntent.putExtra(Intent.EXTRA_TEXT, notifText);
        shareIntent = Intent.createChooser(shareIntent, context.getString(R.string.share_with));
        shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(Intent.createChooser(shareIntent, getContext().getString(R.string.chooser_market)));
    }
}

package com.arnaudpiroelle.muzei.marvel.source.command;

import android.content.Context;
import android.content.Intent;

import com.arnaudpiroelle.muzei.marvel.R;
import com.arnaudpiroelle.muzei.marvel.core.inject.Injector;
import com.google.android.apps.muzei.api.Artwork;
import com.google.android.apps.muzei.api.UserCommand;

import static com.arnaudpiroelle.muzei.marvel.core.inject.Injector.getContext;

public class PublishCommand extends UserCommand implements Command {

    public PublishCommand() {
        super(2, getContext().getString(R.string.command_publish));
    }

    @Override
    public void execute(Artwork artwork) {
        Context context = Injector.getContext();

        String detailUrl = artwork.getImageUri().toString();
        String artist = context.getResources().getString(R.string.marvel_copyright).trim();

        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        String appUrl = context.getString(R.string.app_url);
        String notifText = String.format(context.getString(R.string.share_template), artwork.getTitle().trim(), artist, detailUrl, appUrl);

        shareIntent.putExtra(Intent.EXTRA_TEXT, notifText);
        context.startActivity(shareIntent);
    }
}

Fix crash for share image