package org.intermine.webservice.server;

/*
 * Copyright (C) 2002-2011 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */

import org.intermine.webservice.server.output.Output;

/**
 * Http status code dictionary.
 * @author Jakub Kulaviak
 **/
public class StatusDictionary
{
    /**
     * @param statusCode status code
     * @return short description of specified status code
     */
    public static String getDescription(int statusCode) {
        switch (statusCode) {
            case Output.SC_BAD_REQUEST:
                return "There is a problem on the client side (in the browser). Bad request. ";
            case Output.SC_FORBIDDEN:
                return "Forbidden. ";
            case Output.SC_INTERNAL_SERVER_ERROR:
                return "Internal server error. ";
            case Output.SC_NO_CONTENT:
                return "Resource representation is empty. ";
            case Output.SC_NOT_FOUND:
                return "Resource not found. ";
            case Output.SC_OK:
                return "OK";
            default:
                return "";
        }
    }
}

package org.intermine.webservice.server;

/*
 * Copyright (C) 2002-2011 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */

import org.intermine.webservice.server.output.Output;

/**
 * HTTP status code dictionary.
 * @author Jakub Kulaviak
 **/
public class StatusDictionary
{
    /**
     * @param statusCode status code
     * @return short description of specified status code
     */
    public static String getDescription(int statusCode) {
        String ret;
    	switch (statusCode) {
            case Output.SC_BAD_REQUEST:
                ret = "Bad request. There was a problem with your request parameters:"; break;
            case Output.SC_FORBIDDEN:
                ret = "Forbidden. You do not have access to some part of this query - please log in."; break;
            case Output.SC_INTERNAL_SERVER_ERROR:
                ret = "Internal server error."; break;
            case Output.SC_NO_CONTENT:
                ret = "Resource representation is empty."; break;
            case Output.SC_NOT_FOUND:
                ret = "Resource not found."; break;
            case Output.SC_OK:
                ret = "OK"; break;
            default:
                ret = "Unknown Status";
        }
    	return statusCode + " " + ret;
    }
}

Include the status code in the string, and nicer messages


/*
 * Copyright 2012 the original author or 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.
 */

/**
 * Types for declaring and using Software Components.
 *
 * @since 1.4
 */
@org.gradle.api.Incubating
package org.gradle.api.component;

/*
 * Copyright 2012 the original author or 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.
 */

/**
 * Types for declaring and using Software Components.
 *
 * @since 1.4
 */
@org.gradle.api.Incubating
@org.gradle.api.NonNullApi
package org.gradle.api.component;

Cover `org.gradle.api.component` with nullability annotations


package seedu.emeraldo.commons.core;

/**
 * Container for user visible messages.
 */
public class Messages {

    public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command";
    public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s";
    public static final String MESSAGE_INVALID_TASK_DISPLAYED_INDEX = "The task index provided is invalid";
    public static final String MESSAGE_TASKS_LISTED_OVERVIEW = "%1$d tasks listed!";

}

package seedu.emeraldo.commons.core;

import seedu.emeraldo.logic.commands.HelpCommand;

/**
 * Container for user visible messages.
 */
public class Messages {

    public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command!\n"
    		+ HelpCommand.MESSAGE_USAGE;
    public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s";
    public static final String MESSAGE_INVALID_TASK_DISPLAYED_INDEX = "The task index provided is invalid";
    public static final String MESSAGE_TASKS_LISTED_OVERVIEW = "%1$d tasks listed!";

}

Change message when an unknown command word is input


package com.novoda.downloadmanager.demo.simple;

import com.novoda.downloadmanager.lib.DownloadManager;

class Download {
    private final String title;
    private final String fileName;
    private final int downloadStatus;

    public Download(String title, String fileName, int downloadStatus) {
        this.title = title;
        this.fileName = fileName;
        this.downloadStatus = downloadStatus;
    }

    public String getTitle() {
        return title;
    }

    public String getFileName() {
        return fileName;
    }

    public String getDownloadStatusText() {
        if (downloadStatus == DownloadManager.STATUS_RUNNING) {
            return "Downloading";
        } else if (downloadStatus == DownloadManager.STATUS_SUCCESSFUL) {
            return "Complete";
        } else if (downloadStatus == DownloadManager.STATUS_FAILED) {
            return "Failed";
        } else if (downloadStatus == DownloadManager.STATUS_PENDING) {
            return "Queued";
        } else if (downloadStatus == DownloadManager.STATUS_PAUSED) {
            return "Paused";
        } else {
            return "WTH";
        }
    }
}

package com.novoda.downloadmanager.demo.simple;

import com.novoda.downloadmanager.lib.DownloadManager;

class Download {
    private final String title;
    private final String fileName;
    private final int downloadStatus;

    public Download(String title, String fileName, int downloadStatus) {
        this.title = title;
        this.fileName = fileName;
        this.downloadStatus = downloadStatus;
    }

    public String getTitle() {
        return title;
    }

    public String getFileName() {
        return fileName;
    }

    public String getDownloadStatusText() {
        if (downloadStatus == DownloadManager.STATUS_RUNNING) {
            return "Downloading";
        } else if (downloadStatus == DownloadManager.STATUS_SUCCESSFUL) {
            return "Complete";
        } else if (downloadStatus == DownloadManager.STATUS_FAILED) {
            return "Failed";
        } else if (downloadStatus == DownloadManager.STATUS_PENDING) {
            return "Queued";
        } else if (downloadStatus == DownloadManager.STATUS_PAUSED) {
            return "Paused";
        } else if (downloadStatus == DownloadManager.STATUS_DELETING) {
            return "Deleting";
        } else {
            return "WTH";
        }
    }
}

Add deleting status text to the demo adapter


/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
 *
 * 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 java.util.zip;

/**
 * DataFormatException is used to indicate an error in the format of a
 * particular data stream.
 */
public class DataFormatException extends Exception {

	/**
	 * Constructs a new instance of this class with its walkback filled in.
	 *
	 */
	public DataFormatException() {
		super();
	}

	/**
	 * Constructs a new instance of this class with its walkback and message
	 * filled in.
	 *
	 * @param detailMessage
	 *            String The detail message for the exception.
	 */
	public DataFormatException(String detailMessage) {
		super(detailMessage);
	}
}

/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
 *
 * 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 java.util.zip;

/**
 * DataFormatException is used to indicate an error in the format of a
 * particular data stream.
 */
public class DataFormatException extends Exception {

    private static final long serialVersionUID = 2219632870893641452L;

    /**
     * Constructs a new instance of this class with its walkback filled in.
     *
     */
    public DataFormatException() {
        super();
    }

    /**
     * Constructs a new instance of this class with its walkback and message
     * filled in.
     *
     * @param detailMessage
     *            String The detail message for the exception.
     */
    public DataFormatException(String detailMessage) {
        super(detailMessage);
    }
}

Add constant SUID and minor reformatting


package edu.usc.glidein.service.state;

public enum SiteEventCode implements EventCode
{
	SUBMIT,				/* User requested submit */
	INSTALL_SUCCESS,	/* Condor installed successfully */
	INSTALL_FAILED,		/* Condor installation failed */
	REMOVE,				/* User requested remove */
	UNINSTALL_SUCCESS,	/* Condor uninstalled successfully */
	UNINSTALL_FAILED,	/* Condor uninstall failed */
	GLIDEIN_FINISHED,	/* Glidein finished */
	DELETE				/* User requested delete */
}

package edu.usc.glidein.service.state;

public enum SiteEventCode implements EventCode
{
	SUBMIT,				/* User requested submit */
	INSTALL_SUCCESS,	/* Condor installed successfully */
	INSTALL_FAILED,		/* Condor installation failed */
	REMOVE,				/* User requested remove */
	UNINSTALL_SUCCESS,	/* Condor uninstalled successfully */
	UNINSTALL_FAILED,	/* Condor uninstall failed */
	GLIDEIN_DELETED,	/* Glidein deleted */
	DELETE				/* User requested delete */
}

Change GLIDEIN_FINISHED to GLIDEIN_DELETED to make it clear when this event occurs


package com.github.yuri0x7c1.ofbiz.explorer.common.ui.view;

import org.vaadin.spring.sidebar.annotation.FontAwesomeIcon;
import org.vaadin.spring.sidebar.annotation.SideBarItem;

import com.github.yuri0x7c1.ofbiz.explorer.common.ui.sidebar.Sections;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringView;
import com.vaadin.ui.VerticalLayout;

@SpringView(name = "")
@SideBarItem(sectionId = Sections.VIEWS, caption = "Home", order = 0)
@FontAwesomeIcon(FontAwesome.HOME)
public class HomeView extends VerticalLayout implements View {

    public HomeView() {
        setSpacing(true);
        setMargin(true);
    }

    @Override
    public void enter(ViewChangeListener.ViewChangeEvent event) {
    }
}

package com.github.yuri0x7c1.ofbiz.explorer.common.ui.view;

import org.vaadin.spring.sidebar.annotation.SideBarItem;
import org.vaadin.spring.sidebar.annotation.VaadinFontIcon;

import com.github.yuri0x7c1.ofbiz.explorer.common.ui.sidebar.Sections;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.spring.annotation.SpringView;
import com.vaadin.ui.VerticalLayout;

@SpringView(name = "")
@SideBarItem(sectionId = Sections.VIEWS, caption = "Home", order = 0)
@VaadinFontIcon(VaadinIcons.HOME)
public class HomeView extends VerticalLayout implements View {

    public HomeView() {
        setSpacing(true);
        setMargin(true);
    }

    @Override
    public void enter(ViewChangeListener.ViewChangeEvent event) {
    }
}

Use vaadin icon instead font awesome icon for home page


/*
 * Copyright 2016 Andrey Tolpeev
 *
 * 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.vase4kin.teamcityapp.api.cache;

import com.github.vase4kin.teamcityapp.navigation.api.NavigationNode;
import com.github.vase4kin.teamcityapp.runbuild.api.Branches;

import java.util.concurrent.TimeUnit;

import io.rx_cache.DynamicKey;
import io.rx_cache.EvictDynamicKey;
import io.rx_cache.LifeCache;
import rx.Observable;

/**
 * Cache providers
 */
public interface CacheProviders {

    // TODO: Increase cache to 24 hours? Good idea, huh?
    @LifeCache(duration = 1, timeUnit = TimeUnit.HOURS)
    Observable<NavigationNode> listBuildTypes(Observable<NavigationNode> navigationNodeObservable, DynamicKey dynamicKey, EvictDynamicKey evictDynamicKey);

    @LifeCache(duration = 1, timeUnit = TimeUnit.MINUTES)
    Observable<Branches> listBranches(Observable<Branches> branchesObservable, DynamicKey buildTypeId);
}

/*
 * Copyright 2016 Andrey Tolpeev
 *
 * 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.vase4kin.teamcityapp.api.cache;

import com.github.vase4kin.teamcityapp.navigation.api.NavigationNode;
import com.github.vase4kin.teamcityapp.runbuild.api.Branches;

import java.util.concurrent.TimeUnit;

import io.rx_cache.DynamicKey;
import io.rx_cache.EvictDynamicKey;
import io.rx_cache.LifeCache;
import rx.Observable;

/**
 * Cache providers
 */
public interface CacheProviders {

    @LifeCache(duration = 1, timeUnit = TimeUnit.DAYS)
    Observable<NavigationNode> listBuildTypes(Observable<NavigationNode> navigationNodeObservable, DynamicKey dynamicKey, EvictDynamicKey evictDynamicKey);

    @LifeCache(duration = 1, timeUnit = TimeUnit.MINUTES)
    Observable<Branches> listBranches(Observable<Branches> branchesObservable, DynamicKey buildTypeId);
}

Increase build types cache life for one day


package Debrief.Wrappers.Track;

import Debrief.Wrappers.FixWrapper;
import MWC.GUI.Plottables;
import MWC.GenericData.HiResDate;

public class FixWrapperCollisionCheck {

	/**
	 * We are creating this method because the following ticket
	 * https://github.com/debrief/debrief/issues/4894
	 *
	 * FixWrapper were initially adding with a +1 time delay to avoid collisions.
	 *
	 * Collision check modifies the time in the fixWrapper given to adapt it to
	 * avoid collision.
	 *
	 * @param _fixWrapper       FixWrapper to modify
	 * @param _currentPlotables List of all the Editables
	 */
	public static void correctTimeCollision(final FixWrapper _fixWrapper, final Plottables _currentPlotables) {
		long timeToAdd = _fixWrapper.getTime().getMicros();
		while (_currentPlotables.contains(_fixWrapper)) {
			timeToAdd += 1000; // add 1 second
			_fixWrapper.getFix().setTime(new HiResDate(timeToAdd / 1000L));
		}
	}
}

package Debrief.Wrappers.Track;

import java.util.Enumeration;

import Debrief.Wrappers.FixWrapper;
import MWC.GUI.Editable;
import MWC.GUI.Plottables;
import MWC.GenericData.HiResDate;

public class FixWrapperCollisionCheck {

	/**
	 * We are creating this method because the following ticket
	 * https://github.com/debrief/debrief/issues/4894
	 *
	 * FixWrapper were initially adding with a +1 time delay to avoid collisions.
	 *
	 * Collision check modifies the time in the fixWrapper given to adapt it to
	 * avoid collision.
	 *
	 * @param _fixWrapper       FixWrapper to modify
	 * @param _currentPlotables List of all the Editables
	 */
	public static void correctTimeCollision(final FixWrapper _fixWrapper, final Plottables _currentPlotables) {
		long timeToAdd = _fixWrapper.getTime().getMicros();

		// First check if the exact instance is the list.
		final Enumeration<Editable> elementsEnum = _currentPlotables.elements();
		while (elementsEnum.hasMoreElements()) {
			if (elementsEnum.nextElement() == _fixWrapper) {
				// We have found it.
				return;
			}
		}

		while (_currentPlotables.contains(_fixWrapper)) {
			timeToAdd += 1000; // add 1 second
			_fixWrapper.getFix().setTime(new HiResDate(timeToAdd / 1000L));
		}
	}
}

Check if the exact item already exists, and don't correct it.


package com.gentics.mesh.distributed.containers;

import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;

public final class UnixUtils {

	public static int getUid() throws IOException {
		InputStream in = null;
		try {
			String userName = System.getProperty("user.name");
			String command = "id -u " + userName;
			Process child = Runtime.getRuntime().exec(command);

			// Get the input stream and read from it
			in = child.getInputStream();
			String output = IOUtils.toString(in);
			return Integer.valueOf(output);
		} finally {
			if (in != null) {
				in.close();
			}
		}
	}

}

package com.gentics.mesh.distributed.containers;

import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;

public final class UnixUtils {

	public static int getUid() throws IOException {
		InputStream in = null;
		try {
			String userName = System.getProperty("user.name");
			String command = "id -u " + userName;
			Process child = Runtime.getRuntime().exec(command);

			// Get the input stream and read from it
			in = child.getInputStream();
			String output = IOUtils.toString(in);
			return Integer.valueOf(output.trim());
		} finally {
			if (in != null) {
				in.close();
			}
		}
	}

}

Trim newlines from output string


package fortiss.gui.listeners.button;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import fortiss.gui.Designer;
import fortiss.gui.LoadingScreen;
import fortiss.gui.listeners.helper.FileManager;
import fortiss.simulation.Simulation;

public class AcceptListener extends MouseAdapter {

	public static Simulation sim;
	public static LoadingScreen loadingScreen = new LoadingScreen();
	private Thread simt;

	/**
	 * Initializes the simulation. Creates a descriptor file for every building and
	 * a configuration file for the simulation parameters, disposes the interactive
	 * simulator window.
	 */
	@Override
	public void mouseClicked(MouseEvent e) {
		FileManager fm = new FileManager();
		fm.writeMemapModel();
		fm.writeBuildingDescriptorFiles();
		fm.writeParameterConfigFile(); // Should be called after writeDescriptorFiles()

		sim = new Simulation();
		simt = new Thread(sim);
		simt.start();

		Designer.frame.dispose();
	}
}

package fortiss.gui.listeners.button;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import fortiss.gui.LoadingScreen;
import fortiss.gui.listeners.helper.FileManager;
import fortiss.simulation.Simulation;

public class AcceptListener extends MouseAdapter {

	public static Simulation sim;
	public static LoadingScreen loadingScreen = new LoadingScreen();
	private Thread simt;

	/**
	 * Initializes the simulation. Creates a descriptor file for every building and
	 * a configuration file for the simulation parameters, disposes the interactive
	 * simulator window.
	 */
	@Override
	public void mouseClicked(MouseEvent e) {
		FileManager fm = new FileManager();
		fm.writeMemapModel();
		fm.writeBuildingDescriptorFiles();
		fm.writeParameterConfigFile(); // Should be called after writeDescriptorFiles()

		sim = new Simulation();
		simt = new Thread(sim);
		simt.start();
	}
}

Fix warning related to deserialization


package com.epam.jobizer.plugin;

import hudson.tasks.Builder;
import lombok.extern.java.Log;

@Log
public class JobConfigurationBuilder extends Builder {
}

package com.epam.jobizer.plugin;

import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.tasks.Builder;
import lombok.extern.java.Log;

@Log
public class JobConfigurationBuilder extends Builder {
    @Override
    public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) {
        log.info("Hello from Jenkins");
        // This is where you 'build' the project.
        // Since this is a dummy, we just say 'hello world' and call that a build.

        // This also shows how you can consult the global configuration of the builder
        return true;
    }

}

Remove unnecessary annotation due to failure during plugin start


package fr.masciulli.drinks.fragment;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import fr.masciulli.drinks.R;

public class AboutDialogFragment extends DialogFragment {
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        LayoutInflater inflater = getActivity().getLayoutInflater();

        View root = inflater.inflate(R.layout.dialog_about, null);

        TextView versionNameView = (TextView) root.findViewById(R.id.version_name);

        try {
            PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
            versionNameView.setText(pInfo.versionName);
        } catch (PackageManager.NameNotFoundException e) {
            versionNameView.setText(getString(R.string.unknown_version));
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder
                .setPositiveButton(getString(R.string.about_ok), null)
                .setView(root);

        return builder.create();
    }
}

package fr.masciulli.drinks.fragment;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import butterknife.ButterKnife;
import butterknife.InjectView;
import fr.masciulli.drinks.R;

public class AboutDialogFragment extends DialogFragment {

    @InjectView(R.id.version_name) TextView versionNameView;

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        LayoutInflater inflater = getActivity().getLayoutInflater();

        View root = inflater.inflate(R.layout.dialog_about, null);
        ButterKnife.inject(this, root);

        try {
            PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
            versionNameView.setText(pInfo.versionName);
        } catch (PackageManager.NameNotFoundException e) {
            versionNameView.setText(getString(R.string.unknown_version));
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder
                .setPositiveButton(getString(R.string.about_ok), null)
                .setView(root);

        return builder.create();
    }
}

Use ButterKnife in About Dialog


package com.catpeds.rest.resource;

import java.util.Objects;

import org.springframework.hateoas.ResourceSupport;

import com.catpeds.model.Pedigree;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * {@link Pedigree}'s {@link ResourceSupport}
 *
 * @author padriano
 *
 */
public class PedigreeResource extends ResourceSupport {

	/**
	 * Pedigree information content
	 */
	private final Pedigree pedigree;

	@JsonCreator
	public PedigreeResource(@JsonProperty("pedigree") Pedigree pedigree) {
		this.pedigree = pedigree;
	}

	/**
	 * @see #pedigree
	 *
	 * @return the pedigree
	 */
	public Pedigree getPedigree() {
		return pedigree;
	}

	/**
	 * @see org.springframework.hateoas.ResourceSupport#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (!super.equals(obj)) {
			return false;
		}
		if (Objects.equals(pedigree, ((PedigreeResource) obj).getPedigree())) {
			return true;
		}
		return false;
	}

	/**
	 * @see org.springframework.hateoas.ResourceSupport#hashCode()
	 */
	@Override
	public int hashCode() {
		return Objects.hash(super.hashCode(), pedigree);
	}
}

package com.catpeds.rest.resource;

import java.util.Objects;

import org.springframework.hateoas.ResourceSupport;

import com.catpeds.model.Pedigree;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * {@link Pedigree}'s {@link ResourceSupport}
 *
 * @author padriano
 *
 */
public class PedigreeResource extends ResourceSupport {

	/**
	 * Pedigree information content
	 */
	private final Pedigree pedigree;

	@JsonCreator
	public PedigreeResource(@JsonProperty("pedigree") Pedigree pedigree) {
		this.pedigree = pedigree;
	}

	/**
	 * @see #pedigree
	 *
	 * @return the pedigree
	 */
	public Pedigree getPedigree() {
		return pedigree;
	}

	/**
	 * @see org.springframework.hateoas.ResourceSupport#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (!super.equals(obj)) {
			return false;
		}
		return Objects.equals(pedigree, ((PedigreeResource) obj).getPedigree());
	}

	/**
	 * @see org.springframework.hateoas.ResourceSupport#hashCode()
	 */
	@Override
	public int hashCode() {
		return Objects.hash(super.hashCode(), pedigree);
	}
}

Remove non required if else statement


// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.debug.ui.editors;

import org.eclipse.ui.editors.text.TextEditor;

/**
 * A simplistic Javascript editor which supports its own key binding scope.
 */
public class JsEditor extends TextEditor {

  /** The ID of this editor as defined in plugin.xml */
  public static final String EDITOR_ID =
      "org.chromium.debug.ui.editors.JsEditor"; //$NON-NLS-1$

  /** The ID of the editor context menu */
  public static final String EDITOR_CONTEXT = EDITOR_ID + ".context"; //$NON-NLS-1$

  /** The ID of the editor ruler context menu */
  public static final String RULER_CONTEXT = EDITOR_CONTEXT + ".ruler"; //$NON-NLS-1$

  protected void initializeEditor() {
    super.initializeEditor();
    setEditorContextMenuId(EDITOR_CONTEXT);
    setRulerContextMenuId(RULER_CONTEXT);
  }

  public JsEditor() {
    super();
    setSourceViewerConfiguration(new JsSourceViewerConfiguration());
    setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope", //$NON-NLS-1$
        "org.chromium.debug.ui.editors.JsEditor.context" }); //$NON-NLS-1$
  }

}

// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.debug.ui.editors;

import org.eclipse.ui.editors.text.TextEditor;

/**
 * A simplistic Javascript editor which supports its own key binding scope.
 */
public class JsEditor extends TextEditor {

  /** The ID of this editor as defined in plugin.xml */
  public static final String EDITOR_ID =
      "org.chromium.debug.ui.editors.JsEditor"; //$NON-NLS-1$

  /** The ID of the editor context menu */
  public static final String EDITOR_CONTEXT = EDITOR_ID + ".context"; //$NON-NLS-1$

  /** The ID of the editor ruler context menu */
  public static final String RULER_CONTEXT = EDITOR_ID + ".ruler"; //$NON-NLS-1$

  @Override
  protected void initializeEditor() {
    super.initializeEditor();
    setEditorContextMenuId(EDITOR_CONTEXT);
    setRulerContextMenuId(RULER_CONTEXT);
  }

  public JsEditor() {
    super();
    setSourceViewerConfiguration(new JsSourceViewerConfiguration());
    setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope", //$NON-NLS-1$
        "org.chromium.debug.ui.editors.JsEditor.context" }); //$NON-NLS-1$
  }

}

Fix ruler menu for breakpoints


package com.emc.pravega.demo;

import java.time.Duration;

import com.emc.pravega.service.contracts.StreamSegmentStore;
import com.emc.pravega.service.server.host.handler.PravegaConnectionListener;
import com.emc.pravega.service.server.mocks.InMemoryServiceBuilder;
import com.emc.pravega.service.server.store.ServiceBuilderConfig;
import com.emc.pravega.stream.mock.MockStreamManager;

import lombok.Cleanup;

public class StartLocalService {

    static final int PORT = 9090;
    static final String SCOPE = "Scope";
    static final String STREAM_NAME = "Foo";

    public static void main(String[] args) throws Exception {
        @Cleanup
        InMemoryServiceBuilder serviceBuilder = new InMemoryServiceBuilder(ServiceBuilderConfig.getDefaultConfig());
        serviceBuilder.getContainerManager().initialize(Duration.ofMinutes(1)).get();
        StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
        @Cleanup
        PravegaConnectionListener server = new PravegaConnectionListener(false, PORT, store);
        server.startListening();

        @Cleanup
        MockStreamManager streamManager = new MockStreamManager(SCOPE, "localhost", StartLocalService.PORT);
        streamManager.createStream(STREAM_NAME, null);

        Thread.sleep(60000);

    }
}

package com.emc.pravega.demo;

import java.time.Duration;

import com.emc.pravega.service.contracts.StreamSegmentStore;
import com.emc.pravega.service.server.host.handler.PravegaConnectionListener;
import com.emc.pravega.service.server.mocks.InMemoryServiceBuilder;
import com.emc.pravega.service.server.store.ServiceBuilderConfig;
import com.emc.pravega.stream.mock.MockStreamManager;

import lombok.Cleanup;

public class StartLocalService {

    static final int PORT = 9090;
    static final String SCOPE = "Scope";
    static final String STREAM_NAME = "Foo";

    public static void main(String[] args) throws Exception {
        @Cleanup
        InMemoryServiceBuilder serviceBuilder = new InMemoryServiceBuilder(ServiceBuilderConfig.getDefaultConfig());
        serviceBuilder.getContainerManager().initialize(Duration.ofMinutes(1)).get();
        StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
        @Cleanup
        PravegaConnectionListener server = new PravegaConnectionListener(false, PORT, store);
        server.startListening();

        @Cleanup
        MockStreamManager streamManager = new MockStreamManager(SCOPE, "localhost", StartLocalService.PORT);
        streamManager.createStream(STREAM_NAME, null);

        Thread.sleep(60000);
        System.exit(0);
    }
}

Work around service not exiting.


package info.u_team.u_team_test.init;

import info.u_team.u_team_core.util.registry.BusRegister;

public class TestCommonBusRegister {

	public static void register() {
		BusRegister.registerMod(TestBiomes::registerMod);
		BusRegister.registerMod(TestBlocks::registerMod);
		BusRegister.registerMod(TestContainers::registerMod);
		BusRegister.registerMod(TestEffects::registerMod);
		BusRegister.registerMod(TestEnchantments::registerMod);
		BusRegister.registerMod(TestEntityTypes::registerMod);
		BusRegister.registerMod(TestGlobalLootModifiers::registerMod);
		BusRegister.registerMod(TestItems::registerMod);
		BusRegister.registerMod(TestModDimensions::registerMod);
		BusRegister.registerMod(TestPotions::registerMod);
		BusRegister.registerMod(TestSounds::registerMod);
		BusRegister.registerMod(TestTileEntityTypes::registerMod);
	}

}

package info.u_team.u_team_test.init;

import info.u_team.u_team_core.api.construct.*;
import info.u_team.u_team_core.util.registry.BusRegister;

@Construct()
public class TestCommonBusRegister implements IModConstruct {

	@Override
	public void construct() {
		BusRegister.registerMod(TestBiomes::registerMod);
		BusRegister.registerMod(TestBlocks::registerMod);
		BusRegister.registerMod(TestContainers::registerMod);
		BusRegister.registerMod(TestEffects::registerMod);
		BusRegister.registerMod(TestEnchantments::registerMod);
		BusRegister.registerMod(TestEntityTypes::registerMod);
		BusRegister.registerMod(TestGlobalLootModifiers::registerMod);
		BusRegister.registerMod(TestItems::registerMod);
		BusRegister.registerMod(TestModDimensions::registerMod);
		BusRegister.registerMod(TestPotions::registerMod);
		BusRegister.registerMod(TestSounds::registerMod);
		BusRegister.registerMod(TestTileEntityTypes::registerMod);
	}

}

Implement the construct annotation in the common bus register


package valandur.webapi.serialize.view.misc;

import com.fasterxml.jackson.annotation.JsonValue;
import org.spongepowered.api.util.weighted.NestedTableEntry;
import org.spongepowered.api.util.weighted.RandomObjectTable;
import org.spongepowered.api.util.weighted.TableEntry;
import org.spongepowered.api.util.weighted.WeightedObject;
import valandur.webapi.api.serialize.BaseView;

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

public class RandomObjectTableView extends BaseView<RandomObjectTable<Object>> {

    @JsonValue
    public Map<Double, Object> entries;

    public RandomObjectTableView(RandomObjectTable<Object> value) {
        super(value);

        entries = new HashMap<>();
        for (TableEntry entry : value.getEntries()) {
            if (entry instanceof NestedTableEntry) {
                try {
                    // Get the property with reflection because it's not exposed for some reason
                    Field field = NestedTableEntry.class.getDeclaredField("table");
                    field.setAccessible(true);
                    Object tbl = field.get(entry);
                    entries.put(entry.getWeight(), tbl);
                } catch (IllegalAccessException | NoSuchFieldException ignored) { }
            } else if (entry instanceof WeightedObject) {
                entries.put(entry.getWeight(), ((WeightedObject)entry).get());
            }
        }
    }
}

package valandur.webapi.serialize.view.misc;

import com.fasterxml.jackson.annotation.JsonValue;
import org.spongepowered.api.util.weighted.NestedTableEntry;
import org.spongepowered.api.util.weighted.RandomObjectTable;
import org.spongepowered.api.util.weighted.TableEntry;
import org.spongepowered.api.util.weighted.WeightedObject;
import valandur.webapi.api.serialize.BaseView;

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

public class RandomObjectTableView extends BaseView<RandomObjectTable> {

    @JsonValue
    public Map<Double, Object> entries;

    public RandomObjectTableView(RandomObjectTable<Object> value) {
        super(value);

        entries = new HashMap<>();
        for (TableEntry entry : value.getEntries()) {
            if (entry instanceof NestedTableEntry) {
                try {
                    // Get the property with reflection because it's not exposed for some reason
                    Field field = NestedTableEntry.class.getDeclaredField("table");
                    field.setAccessible(true);
                    Object tbl = field.get(entry);
                    entries.put(entry.getWeight(), tbl);
                } catch (IllegalAccessException | NoSuchFieldException ignored) { }
            } else if (entry instanceof WeightedObject) {
                entries.put(entry.getWeight(), ((WeightedObject)entry).get());
            }
        }
    }
}

Fix weighted/chance tables not serializing


package io.vertx.ext.web;

import io.vertx.codegen.annotations.VertxGen;

@VertxGen
public interface MIMEHeader extends ParsedHeaderValue{

  /**
   * Gets the parsed component part of the MIME. This is the string between the beginning and the first @{code '/'}
   * of the MIME
   * @return The component of the MIME this represents
   */
  String component();

  /**
   * Gets the parsed subcomponent part of the MIME. This is the string between the first @{code '/'} and the
   * @{code ';'} or the end of the MIME
   * @return The subcomponent of the MIME this represents
   */
  String subComponent();

}

package io.vertx.ext.web;

import io.vertx.codegen.annotations.VertxGen;

@VertxGen
public interface MIMEHeader extends ParsedHeaderValue{

  /**
   * Gets the parsed component part of the MIME. This is the string between the beginning and the first {@code '/'}
   * of the MIME
   * @return The component of the MIME this represents
   */
  String component();

  /**
   * Gets the parsed subcomponent part of the MIME. This is the string between the first {@code '/'} and the
   * {@code ';'} or the end of the MIME
   * @return The subcomponent of the MIME this represents
   */
  String subComponent();

}

Fix incorrect javadoc {@code} taglet


//----------------------------------------------------------------------------//
//                                                                            //
//                            V e r t e x V i e w                             //
//                                                                            //
//  Copyright (C) Herve Bitteur 2000-2009. All rights reserved.               //
//  This software is released under the GNU General Public License.           //
//  Please contact users@audiveris.dev.java.net to report bugs & suggestions. //
//----------------------------------------------------------------------------//
//
package omr.graph;

import java.awt.*;

/**
 * Interface VertexView defines the interface needed to handle the
 * rendering of a vertex.
 *
 * @author Hervé Bitteur
 * @version $Id$
 */
public interface VertexView
{
    //~ Methods ----------------------------------------------------------------

    //--------------//
    // getRectangle //
    //--------------//
    /**
     * Return the display rectangle used by the rendering of the vertex
     *
     * @return the bounding rectangle in the display space
     */
    Rectangle getRectangle ();

    //--------//
    // render //
    //--------//
    /**
     * Render the vertex
     *
     * @param g the graphics context
     *
     * @param drawBorders should vertex borders be drawn
     * @return true if actually rendered, i.e. is displayed
     */
    boolean render (Graphics g,
                    boolean  drawBorders);
}

//----------------------------------------------------------------------------//
//                                                                            //
//                            V e r t e x V i e w                             //
//                                                                            //
//  Copyright (C) Herve Bitteur 2000-2009. All rights reserved.               //
//  This software is released under the GNU General Public License.           //
//  Please contact users@audiveris.dev.java.net to report bugs & suggestions. //
//----------------------------------------------------------------------------//
//
package omr.graph;

import java.awt.*;

/**
 * Interface VertexView defines the interface needed to handle the
 * rendering of a vertex.
 *
 * @author Hervé Bitteur
 * @version $Id$
 */
public interface VertexView
{
    //~ Methods ----------------------------------------------------------------

    //--------------//
    // getRectangle //
    //--------------//
    /**
     * Return the display rectangle used by the rendering of the vertex
     *
     * @return the bounding rectangle in the display space
     */
    Rectangle getRectangle ();

    //--------//
    // render //
    //--------//
    /**
     * Render the vertex
     *
     * @param g the graphics context
     * @param drawBorders should vertex borders be drawn
     *
     * @return true if actually rendered, i.e. is displayed
     */
    boolean render (Graphics g,
                    boolean  drawBorders);
}

Allow user selection at section level


package com.axiomalaska.sos.injector.db;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.axiomalaska.sos.SosInjector;

public class DatabaseSosInjector {
    private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseSosInjector.class);
    private static final String MOCK = "mock";

    public static void main(String[] args){
        if (args.length > 0) {
            String configFile = args[0];
            DatabaseSosInjectorConfig.initialize(configFile);
        }

        try {
            SosInjector sosInjector = null;
            if (System.getProperty(MOCK) != null) {
                //mock
                sosInjector = SosInjector.mock("mock-database-sos-injector",
                        new DatabaseStationRetriever(),
                        new DatabaseObservationRetriever(),
                        true);
                LOGGER.info("Mock SosInjector initialized");
            } else {
                sosInjector = new SosInjector("database-sos-injector",
                        DatabaseSosInjectorConfig.instance().getSosUrl(),
                        DatabaseSosInjectorConfig.instance().getSosAuthenticationToken(),
                        DatabaseSosInjectorConfig.instance().getPublisherInfo(),
                        new DatabaseStationRetriever(),
                        new DatabaseObservationRetriever(),
                        null);

            }
            if (sosInjector == null) {
                throw new NullPointerException("sosInjector is null");
            }
            sosInjector.update();
        } catch (Exception e) {
            LOGGER.error("Sos injection failed", e);
        }
    }
}

package com.axiomalaska.sos.injector.db;

import java.util.concurrent.TimeUnit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.axiomalaska.sos.SosInjector;
import com.google.common.base.Stopwatch;

public class DatabaseSosInjector {
    private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseSosInjector.class);
    private static final String MOCK = "mock";

    public static void main(String[] args){
        if (args.length > 0) {
            String configFile = args[0];
            DatabaseSosInjectorConfig.initialize(configFile);
        }

        Stopwatch stopwatch = Stopwatch.createStarted();
        try {
            SosInjector sosInjector = null;
            if (System.getProperty(MOCK) != null) {
                //mock
                sosInjector = SosInjector.mock("mock-database-sos-injector",
                        new DatabaseStationRetriever(),
                        new DatabaseObservationRetriever(),
                        true);
                LOGGER.info("Mock SosInjector initialized");
            } else {
                sosInjector = new SosInjector("database-sos-injector",
                        DatabaseSosInjectorConfig.instance().getSosUrl(),
                        DatabaseSosInjectorConfig.instance().getSosAuthenticationToken(),
                        DatabaseSosInjectorConfig.instance().getPublisherInfo(),
                        new DatabaseStationRetriever(),
                        new DatabaseObservationRetriever(),
                        null);

            }
            if (sosInjector == null) {
                throw new NullPointerException("sosInjector is null");
            }

            sosInjector.update();
            LOGGER.info("SOS injection finished in {} seconds", stopwatch.elapsed(TimeUnit.SECONDS));
        } catch (Exception e) {
            LOGGER.error("Sos injection failed after {} seconds", stopwatch.elapsed(TimeUnit.SECONDS), e);
        }
    }
}

Add stopwatch to log output and a finished message


package org.keyboardplaying.cron.scheduler;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

/**
 * Tests {@link CronJob}.
 *
 * @author Cyrille Chopelet (http://keyboardplaying.org)
 */
public class CronJobTest {

    private static final String CRON_EVRY_MIN = "* * * * *";

    private Runnable job = new Runnable() {
        @Override
        public void run() {
        }
    };

    /** Ensures the constructor throws a {@link NullPointerException} if the job is {@code null}. */
    @Test(expected = NullPointerException.class)
    public void testNullJob() {
        new CronJob(null, CRON_EVRY_MIN);
    }

    /**
     * Ensures the constructor throws a {@link NullPointerException} if the cron is {@code null}.
     */
    @Test(expected = NullPointerException.class)
    public void testNullCron() {
        new CronJob(job, null);
    }

    /** Tests the getters. */
    @Test
    public void test() {
        CronJob cj = new CronJob(job, CRON_EVRY_MIN);
        assertEquals(job, cj.getJob());
        assertEquals(CRON_EVRY_MIN, cj.getCron());
    }
}

package org.keyboardplaying.cron.scheduler;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

/**
 * Tests {@link CronJob}.
 *
 * @author Cyrille Chopelet (http://keyboardplaying.org)
 */
public class CronJobTest {

    private static final String CRON_EVRY_MIN = "* * * * *";

    private Runnable job = new Runnable() {
        @Override
        public void run() {
        }
    };

    /** Ensures the constructor throws a {@link NullPointerException} if the job is {@code null}. */
    @Test(expected = NullPointerException.class)
    public void testNullJob() {
        new CronJob(null, CRON_EVRY_MIN);
    }

    /**
     * Ensures the constructor throws a {@link NullPointerException} if the cron is {@code null}.
     */
    @Test(expected = NullPointerException.class)
    public void testNullCron() {
        new CronJob(job, null);
    }

    /** Tests the getters. */
    @Test
    public void test() {
        CronJob cj = new CronJob(job, CRON_EVRY_MIN);
        assertEquals(job, cj.getJob());
        assertEquals(CRON_EVRY_MIN, cj.getCron());
    }

    /** Tests the setters. */
    @Test
    public void testSpring() {
        CronJob cj = new CronJob();
        cj.setJob(job);
        cj.setCron(CRON_EVRY_MIN);

        assertEquals(job, cj.getJob());
        assertEquals(CRON_EVRY_MIN, cj.getCron());
    }
}

Test coverage for Spring instantiation (actual tests with Spring will come later)


package com.rabenauge.demo;

import java.nio.*;

/*
 * A class to create directly allocated buffers of native byte order.
 */
public class DirectBuffer {
    public static ByteBuffer nativeByteBuffer(int capacity) {
        ByteBuffer buffer=ByteBuffer.allocateDirect(capacity);
        buffer.order(ByteOrder.nativeOrder());
        return buffer;
    }

    public static ByteBuffer nativeByteBuffer(byte[] array) {
        ByteBuffer buffer=nativeByteBuffer(array.length);
        buffer.put(array).position(0);
        return buffer;
    }

    public static ShortBuffer nativeShortBuffer(int capacity) {
        return nativeByteBuffer(capacity*Short.SIZE>>3).asShortBuffer();
    }

    public static ShortBuffer nativeShortBuffer(short[] array) {
        ShortBuffer buffer=nativeShortBuffer(array.length);
        buffer.put(array).position(0);
        return buffer;
    }

    public static IntBuffer nativeIntBuffer(int capacity) {
        return nativeByteBuffer(capacity*Integer.SIZE>>3).asIntBuffer();
    }

    public static IntBuffer nativeIntBuffer(int[] array) {
        IntBuffer buffer=nativeIntBuffer(array.length);
        buffer.put(array).position(0);
        return buffer;
    }
}

package com.rabenauge.demo;

import java.nio.*;

/*
 * A class to create directly allocated buffers of native byte order.
 */
public class DirectBuffer {
    public static ByteBuffer nativeByteBuffer(int capacity) {
        ByteBuffer buffer=ByteBuffer.allocateDirect(capacity);
        buffer.order(ByteOrder.nativeOrder());
        return buffer;
    }

    public static ByteBuffer nativeByteBuffer(byte[] array) {
        ByteBuffer buffer=nativeByteBuffer(array.length);
        buffer.put(array).position(0);
        return buffer;
    }

    public static ShortBuffer nativeShortBuffer(int capacity) {
        return nativeByteBuffer(capacity*Short.SIZE>>3).asShortBuffer();
    }

    public static ShortBuffer nativeShortBuffer(short[] array) {
        ShortBuffer buffer=nativeShortBuffer(array.length);
        buffer.put(array).position(0);
        return buffer;
    }

    public static IntBuffer nativeIntBuffer(int capacity) {
        return nativeByteBuffer(capacity*Integer.SIZE>>3).asIntBuffer();
    }

    public static IntBuffer nativeIntBuffer(int[] array) {
        IntBuffer buffer=nativeIntBuffer(array.length);
        buffer.put(array).position(0);
        return buffer;
    }

    public static FloatBuffer nativeFloatBuffer(int capacity) {
        return nativeByteBuffer(capacity*Float.SIZE>>3).asFloatBuffer();
    }

    public static FloatBuffer nativeFloatBuffer(float[] array) {
        FloatBuffer buffer=nativeFloatBuffer(array.length);
        buffer.put(array).position(0);
        return buffer;
    }
}

Add float allocators for completeness


package persons;

/**
 * Created by fcmam5 on 11/13/15.
 * Implemented by Mouilah-Sarra
 */
public class Donor extends Personne {
    private static int donNum = 0;
    private int quantite;
    boolean motivation;

    public Donor(String name, String firstName, int age, String grouping, String[] adresse, int quantite, boolean motivation) {
        super(name, firstName, age, grouping, adresse);
        this.donNum++;
        this.quantite = quantite;
        this.motivation = motivation;
    }

    public void setGroupage (String gropage){
        setGrouping(gropage);

}
    public String getGroupage(){
        return getGrouping();
}

    public int getDonNum( ){
        return this.donNum;

    }

    // HOw much he gives ?
    public void setQuantite (int quantite){
    this.quantite=quantite;
}

    public int getQuantite (){
        return this.quantite;
    }

}

package persons;

import java.util.Objects;

/**
 * Created by fcmam5 on 11/13/15.
 * Implemented by Mouilah-Sarra
 */
public class Donor extends Personne {
    private static int donNum = 0;
    private int quantite;
    private boolean motivation;
    private Object donorCard[] = new Object[3]; // [[int DonorKey]|[String email]|[int telNumber]]

    public Donor(String name, String firstName, int age, String grouping, String[] adresse, int quantite, boolean motivation) {
        super(name, firstName, age, grouping, adresse);
        this.donNum++;
        this.quantite = quantite;
        this.motivation = motivation;
    }

    public void setGroupage (String gropage){
        setGrouping(gropage);

}
    public String getGroupage(){
        return getGrouping();
}

    public int getDonNum( ){
        return this.donNum;

    }

    // HOw much he gives ?
    public void setQuantite (int quantite){
    this.quantite=quantite;
}

    public int getQuantite (){
        return this.quantite;
    }

    /**
     *  if He is motivated let's keep his infos in a table :
     *  [[String DonorKey]|[String email]|[int telNumber]]
     *  DonorKey is [firstDon+the name & first's first nameLetter]
     *      Example : "Johny Bob's first donNum was 54 (Was the the 54th donor)"
     *                 His code will be : JB54
     */

    public Donor(String name, String firstName, int age, String grouping, String[] adresse_given, int quantite) {
        super(name, firstName, age, grouping, adresse_given);
        this.quantite = quantite;
        this.motivation = true;

        //Filling DonorCard :
        this.donorCard[0] = name.charAt(0)+firstName.charAt(0)+this.getDonNum(); //Code B-)
        this.donorCard[1] = name;
        this.donorCard[2] = firstName;
    }

}

Set a key to donors


package com.atlassian.plugin.webresource;

import junit.framework.TestCase;

import java.util.HashMap;

public class TestJavascriptWebResourceFormatter extends TestCase
{
    private JavascriptWebResourceFormatter javascriptWebResourceFormatter;

    protected void setUp() throws Exception
    {
        super.setUp();
        javascriptWebResourceFormatter = new JavascriptWebResourceFormatter();
    }

    protected void tearDown() throws Exception
    {
        javascriptWebResourceFormatter = null;
        super.tearDown();
    }

    public void testMatches()
    {
        assertTrue(javascriptWebResourceFormatter.matches("blah.js"));
        assertFalse(javascriptWebResourceFormatter.matches("blah.css"));
    }

    public void testFormatResource()
    {
        final String resourceName = "atlassian.js";
        final String url = "/confluence/download/resources/confluence.web.resources:ajs/atlassian.js";
        assertEquals("<script type=\"text/javascript\" src=\"" + url + "\"></script>\n",
                     javascriptWebResourceFormatter.formatResource(resourceName, url, new HashMap()));
    }
}

package com.atlassian.plugin.webresource;

import junit.framework.TestCase;

import java.util.HashMap;

public class TestJavascriptWebResourceFormatter extends TestCase
{
    private JavascriptWebResourceFormatter javascriptWebResourceFormatter;

    protected void setUp() throws Exception
    {
        super.setUp();
        javascriptWebResourceFormatter = new JavascriptWebResourceFormatter();
    }

    protected void tearDown() throws Exception
    {
        javascriptWebResourceFormatter = null;
        super.tearDown();
    }

    public void testMatches()
    {
        assertTrue(javascriptWebResourceFormatter.matches("blah.js"));
        assertFalse(javascriptWebResourceFormatter.matches("blah.css"));
    }

    public void testFormatResource()
    {
        final String resourceName = "atlassian.js";
        final String url = "/confluence/download/resources/confluence.web.resources:ajs/atlassian.js";
        assertEquals("<script type=\"text/javascript\" src=\"" + url + "\" ></script>\n",
                     javascriptWebResourceFormatter.formatResource(resourceName, url, new HashMap()));
    }
}

Refactor WebResourceManagerImpl to use WebResourceFormatters for javascript and css resources - css resource parameter for IE conditional comments added - also added support for several HTML attributes


package fape.core.planning.search.strategies.plans;

import fape.core.planning.states.State;

import java.util.LinkedList;
import java.util.List;

/**
 * Used to use a sequence of PartialPlanComparator as one.
 *
 * The basic algorithm for comparing two partial plans is to apply the comparators in sequence until it results in an ordering
 * between the two plans. If no comparator is found, the plans are left unordered.
 */
public class SeqPlanComparator implements PartialPlanComparator {

    List<PartialPlanComparator> comparators;

    public SeqPlanComparator(List<PartialPlanComparator> comparators) {
        this.comparators = new LinkedList<>(comparators);
    }

    @Override
    public String shortName() {
        String ret = "";
        for(PartialPlanComparator comp : comparators) {
            ret += comp.shortName() + ",";
        }
        return ret.substring(0, ret.length()-1);
    }

    @Override
    public int compare(State state, State state2) {
        for(PartialPlanComparator comp : comparators) {
            int res = comp.compare(state, state2);
            if(res != 0) {
                return res;
            }
        }
        // no resolver could rank those flaws.
        return 0;
    }
}

package fape.core.planning.search.strategies.plans;

import fape.core.planning.states.State;

import java.util.LinkedList;
import java.util.List;

/**
 * Used to use a sequence of PartialPlanComparator as one.
 *
 * The basic algorithm for comparing two partial plans is to apply the comparators in sequence until it results in an ordering
 * between the two plans. If no comparator is found, the plans are left unordered.
 */
public class SeqPlanComparator implements PartialPlanComparator {

    List<PartialPlanComparator> comparators;

    public SeqPlanComparator(List<PartialPlanComparator> comparators) {
        this.comparators = new LinkedList<>(comparators);
    }

    @Override
    public String shortName() {
        String ret = "";
        for(PartialPlanComparator comp : comparators) {
            ret += comp.shortName() + ",";
        }
        return ret.substring(0, ret.length()-1);
    }

    @Override
    public int compare(State state, State state2) {
        for(PartialPlanComparator comp : comparators) {
            int res = comp.compare(state, state2);
            if(res != 0) {
                return res;
            }
        }

        // tie breaker: makespan
        int diffMakespan = state.getEarliestStartTime(state.pb.end()) - state2.getEarliestStartTime(state2.pb.end());
        if(diffMakespan != 0)
            return diffMakespan;

        // no ranking done, use mID to make deterministic
        return state.mID - state2.mID;
    }
}

Add tie breaker for plan comparators.


package com.flipboard.bottomsheet.commons;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.ImageView;

/**
 * An ImageView that keeps a 1:1 aspect ratio
 */
final class SquareImageView extends ImageView {
    public SquareImageView(Context context) {
        super(context);
    }

    public SquareImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public SquareImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public SquareImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @SuppressWarnings("SuspiciousNameCombination")
    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, widthMeasureSpec);
    }
}

package com.flipboard.bottomsheet.commons;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.ImageView;

/**
 * An ImageView that keeps a 1:1 aspect ratio
 */
final class SquareImageView extends ImageView {
    public SquareImageView(Context context) {
        super(context);
    }

    public SquareImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public SquareImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public SquareImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @SuppressWarnings("UnnecessaryLocalVariable")
    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int bothDimensionsSpec = widthMeasureSpec;
        super.onMeasure(bothDimensionsSpec, bothDimensionsSpec);
    }
}

Use more accurate name for clarity in measuring


package weatherhandler;

import java.util.Date;
import java.text.SimpleDateFormat;

public class Logger {
    final public static int ERROR = 0;
    final public static int WARN = 1;
    final public static int INFO = 2;
    final public static int DEBUG = 3;

    private static int level = Logger.DEBUG;
    private String name;

    public Logger(String name) {
        this.name = name;
    }

    private void log(String level, String[] text) {
        String time = new SimpleDateFormat("hh:mm:ss").format(new Date());
        System.out.println(
            "[" + level + " " + time + "] " +
            this.name + ": " + String.join(" ", text)
        );
    }

    public void debug(String... args) {
        if (Logger.level >= Logger.DEBUG) {
            this.log("DEBUG", args);
        }
    }

    public void info(String... args) {
        if (Logger.level >= Logger.INFO) {
            this.log("INFO", args);
        }
    }

    public void warn(String... args) {
        if (Logger.level >= Logger.WARN) {
            this.log("WARN", args);
        }
    }

    public void error(String... args) {
        this.log("ERROR", args);
    }
}

package weatherhandler;

import java.util.Date;
import java.text.SimpleDateFormat;

public class Logger {
    final public static int ERROR = 0;
    final public static int WARN = 1;
    final public static int INFO = 2;
    final public static int DEBUG = 3;

    private static int level = Logger.DEBUG;
    private String name;

    public Logger(String name) {
        this.name = name;
    }

    private void log(String level, String[] text) {
        String time = new SimpleDateFormat("hh:mm:ss").format(new Date());
        System.err.println(
            "[" + level + " " + time + "] " +
            this.name + ": " + String.join(" ", text)
        );
    }

    public void debug(String... args) {
        if (Logger.level >= Logger.DEBUG) {
            this.log("DEBUG", args);
        }
    }

    public void info(String... args) {
        if (Logger.level >= Logger.INFO) {
            this.log("INFO", args);
        }
    }

    public void warn(String... args) {
        if (Logger.level >= Logger.WARN) {
            this.log("WARN", args);
        }
    }

    public void error(String... args) {
        this.log("ERROR", args);
    }
}

Print logger output to stderr


package com.github.neunkasulle.chronocommand.control;

import com.github.neunkasulle.chronocommand.model.Category;
import com.github.neunkasulle.chronocommand.model.CategoryDAO;
import com.github.neunkasulle.chronocommand.model.DAOHelper;
import org.hibernate.cfg.NotYetImplementedException;

/**
 * Created by Janze on 18.01.2016.
 * Controling startup and shutdown
 */
public class MainControl extends Control {

    private static MainControl ourInstance = new MainControl();

    private MainControl() {
        realm = new com.github.neunkasulle.chronocommand.security.Realm();
    }

    public static MainControl getInstance() {
        return ourInstance;
    }

    private void exceptionHandling() {
        throw new NotYetImplementedException();
    }

    public void startup() {
        DAOHelper.getInstance().startup();

        CategoryDAO.getInstance().saveCategory(new Category("Programming"));
        CategoryDAO.getInstance().saveCategory(new Category("Procrastination"));

        // TODO initiate anything that needs initiating
    }

    public void shutdown() {
        DAOHelper.getInstance().shutdown();

        // TODO initiate anything that needs initiating
    }
}

package com.github.neunkasulle.chronocommand.control;

import com.github.neunkasulle.chronocommand.model.Category;
import com.github.neunkasulle.chronocommand.model.CategoryDAO;
import com.github.neunkasulle.chronocommand.model.DAOHelper;
import com.github.neunkasulle.chronocommand.model.UserDAO;
import com.github.neunkasulle.chronocommand.model.User;
import org.hibernate.cfg.NotYetImplementedException;

/**
 * Created by Janze on 18.01.2016.
 * Controling startup and shutdown
 */
public class MainControl extends Control {

    private static MainControl ourInstance = new MainControl();

    private MainControl() {
        realm = new com.github.neunkasulle.chronocommand.security.Realm();
    }

    public static MainControl getInstance() {
        return ourInstance;
    }

    private void exceptionHandling() {
        throw new NotYetImplementedException();
    }

    public void startup() {
        DAOHelper.getInstance().startup();

        // TODO initiate anything that needs initiating

        // DEBUG fill database with data
        CategoryDAO.getInstance().saveCategory(new Category("Programming"));
        CategoryDAO.getInstance().saveCategory(new Category("Procrastination"));

        User tom = new User();
        tom.setEmail("tom@chronocommand.eu");
        tom.setPassword("cat");
        tom.setUsername("tom");
        UserDAO.getInstance().saveUser(tom);

        User matt = new User();
        matt.setEmail("matt@example.com");
        matt.setPassword("matt");
        matt.setUsername("matt");
        matt.setSupervisor(tom);
        UserDAO.getInstance().saveUser(matt);
    }

    public void shutdown() {
        DAOHelper.getInstance().shutdown();

        // TODO initiate anything that needs initiating
    }
}

Create users on startup for testing purposes


/*
Copyright 2011 Frederic Langlet
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 kanzi.entropy;

import kanzi.EntropyEncoder;
import kanzi.BitStream;
import kanzi.BitStreamException;

public abstract class AbstractEncoder implements EntropyEncoder
{
    @Override
    public abstract boolean encodeByte(byte val);

    @Override
    public abstract BitStream getBitStream();

    // Default implementation: fallback to encodeByte
    // Some implementations should be able to use an optimized algorithm
    @Override
    public int encode(byte[] array, int blkptr, int len)
    {
        if ((array == null) || (blkptr + len > array.length) || (blkptr < 0) || (len < 0))
           return -1;

        int end = blkptr + len;
        int i = blkptr;

        try
        {
           while (i < end)
           {
              if (this.encodeByte(array[i]) == false)
                 return i;

              i++;
           }
        }
        catch (BitStreamException e)
        {
           return i;
        }

        return len;
    }

    @Override
    public void dispose()
    {
    }

}

/*
Copyright 2011 Frederic Langlet
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 kanzi.entropy;

import kanzi.EntropyEncoder;
import kanzi.BitStream;
import kanzi.BitStreamException;

public abstract class AbstractEncoder implements EntropyEncoder
{
    @Override
    public abstract boolean encodeByte(byte val);

    @Override
    public abstract BitStream getBitStream();

    // Default implementation: fallback to encodeByte
    // Some implementations should be able to use an optimized algorithm
    @Override
    public int encode(byte[] array, int blkptr, int len)
    {
        if ((array == null) || (blkptr + len > array.length) || (blkptr < 0) || (len < 0))
           return -1;

        int end = blkptr + len;
        int i = blkptr;

        try
        {
           while (i < end)
           {
              if (this.encodeByte(array[i]) == false)
                 return i;

              i++;
           }
        }
        catch (BitStreamException e)
        {
           return i - blkptr;
        }

        return len;
    }

    @Override
    public void dispose()
    {
    }

}

Fix length calculation in the exception path


/**
 * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
 *
 * 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 io.gravitee.common.http;

/**
 * Represents an HTTP method.
 *
 * @author David BRASSELY (brasseld at gmail.com)
 */
public enum HttpMethod {

  CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, TRACE;
}

/**
 * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
 *
 * 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 io.gravitee.common.http;

/**
 * Represents an HTTP method.
 *
 * @author David BRASSELY (david.brassely at graviteesource.com)
 * @author GraviteeSource Team
 */
public enum HttpMethod {

  CONNECT(1), DELETE(2), GET(3), HEAD(4), OPTIONS(5), PATCH(6), POST(7), PUT(8), TRACE(9);

  private int code;

  HttpMethod(int code) {
    this.code = code;
  }

  public int code() {
    return code;
  }

  public static HttpMethod get(int code) {
    for(HttpMethod method : HttpMethod.values()) {
      if (method.code == code) {
        return method;
      }
    }

    throw new IllegalArgumentException("Invalid HTTP method code");
  }
}

Add code to HTTP method


package info.u_team.u_team_core.util;

import static net.minecraft.client.renderer.model.ModelBakery.STATE_CONTAINER_OVERRIDES;

import java.util.*;

import com.google.common.collect.ImmutableMap;

import net.minecraft.block.*;
import net.minecraft.state.StateContainer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.*;

@OnlyIn(Dist.CLIENT)
public class ModelUtil {

	static {
		if (STATE_CONTAINER_OVERRIDES instanceof ImmutableMap) {
			final Map<ResourceLocation, StateContainer<Block, BlockState>> mutableMap = new HashMap<>();
			STATE_CONTAINER_OVERRIDES.forEach(mutableMap::put);
			STATE_CONTAINER_OVERRIDES = mutableMap;
		}
	}

	public static void addCustomStateContainer(ResourceLocation location, StateContainer<Block, BlockState> container) {
		STATE_CONTAINER_OVERRIDES.put(location, container);
	}

}

package info.u_team.u_team_core.util;

import static net.minecraft.client.renderer.model.ModelBakery.STATE_CONTAINER_OVERRIDES;

import java.util.*;

import com.google.common.collect.*;

import net.minecraft.block.*;
import net.minecraft.state.StateContainer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.*;

@OnlyIn(Dist.CLIENT)
public class ModelUtil {

	static {
		if (STATE_CONTAINER_OVERRIDES instanceof ImmutableMap) {
			final Map<ResourceLocation, StateContainer<Block, BlockState>> mutableMap = new HashMap<>();
			STATE_CONTAINER_OVERRIDES.forEach(mutableMap::put);
			STATE_CONTAINER_OVERRIDES = mutableMap;
		}
	}

	public static void addCustomStateContainer(ResourceLocation location, StateContainer<Block, BlockState> container) {
		STATE_CONTAINER_OVERRIDES.put(location, container);
	}

	public static class EmptyStateContainer extends StateContainer<Block, BlockState> {

		public EmptyStateContainer(Block block) {
			super(block, BlockState::new, new HashMap<>());
		}

		@Override
		public ImmutableList<BlockState> getValidStates() {
			return getOwner().getStateContainer().getValidStates();
		}

	}

}

Add empty state container class as utility


package info.u_team.u_team_test.container;

import info.u_team.u_team_core.container.UTileEntityContainer;
import info.u_team.u_team_test.init.TestContainers;
import info.u_team.u_team_test.tileentity.BasicFluidInventoryTileEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.network.PacketBuffer;

public class BasicFluidInventoryContainer extends UTileEntityContainer<BasicFluidInventoryTileEntity> {

	// Client
	public BasicFluidInventoryContainer(int id, PlayerInventory playerInventory, PacketBuffer buffer) {
		super(TestContainers.BASIC_FLUID_INVENTORY, id, playerInventory, buffer);
	}

	// Server
	public BasicFluidInventoryContainer(int id, PlayerInventory playerInventory, BasicFluidInventoryTileEntity tileEntity) {
		super(TestContainers.BASIC_FLUID_INVENTORY, id, playerInventory, tileEntity);
	}

	@Override
	protected void init(boolean server) {

	}

}

package info.u_team.u_team_test.container;

import info.u_team.u_team_core.container.UTileEntityContainer;
import info.u_team.u_team_test.init.TestContainers;
import info.u_team.u_team_test.tileentity.BasicFluidInventoryTileEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.network.PacketBuffer;

public class BasicFluidInventoryContainer extends UTileEntityContainer<BasicFluidInventoryTileEntity> {

	// Client
	public BasicFluidInventoryContainer(int id, PlayerInventory playerInventory, PacketBuffer buffer) {
		super(TestContainers.BASIC_FLUID_INVENTORY, id, playerInventory, buffer);
	}

	// Server
	public BasicFluidInventoryContainer(int id, PlayerInventory playerInventory, BasicFluidInventoryTileEntity tileEntity) {
		super(TestContainers.BASIC_FLUID_INVENTORY, id, playerInventory, tileEntity);
	}

	@Override
	protected void init(boolean server) {
		appendInventory(tileEntity.getItemSlots(), 2, 9, 8, 41);
		appendPlayerInventory(playerInventory, 8, 91);
	}

}

Add player inventory and basic fluid slots


/* $This file is distributed under the terms of the license in /doc/license.txt$ */

package edu.cornell.mannlib.vitro.webapp.controller;

import org.junit.Assert;
import org.junit.Test;

import edu.cornell.mannlib.vitro.webapp.web.ContentType;

public class EntityControllerTest {

	@Test
	public void testAcceptHeader(){
		EntityController entityController = new EntityController();

		/* Check to see if vitro would send RDF/XML to tabulator */
		String tabulatorsAcceptHeader =
			"text/xml,application/xml,application/xhtml+xml,text/html;q=0.5,text/plain;q=0.5," +
			"image/png,*/*;q=0.1," +
			"application/rdf+xml;q=1.0,text/n3;q=0.4";
		ContentType result = entityController.checkForLinkedDataRequest("http://notUsedInThisTestCase.com/bogus",tabulatorsAcceptHeader);
		Assert.assertTrue( result != null );
		Assert.assertTrue( "application/rdf+xml".equals( result.toString()) );
	}
}

Add a "magic license comment"


/**
 * Copyright 2008 Matthew Hillsdon
 *
 * 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.hillsdon.reviki.wiki.renderer;

import junit.framework.TestCase;

public class TestRendererRegistry extends TestCase {

  private HtmlRenderer _default;

  private RendererRegistry _registry;

  public void setUp() {
    _default = new HtmlRenderer(null, null, null, null);
    _registry = new RendererRegistry(_default);
  }

  /**
   * Test that we can retrieve the default renderer.
   */
  public void testGetDefault() {
    assertNotNull(_registry.getDefaultRenderer());
    assertEquals(_default, _registry.getDefaultRenderer());
  }
}

/**
 * Copyright 2008 Matthew Hillsdon
 *
 * 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.hillsdon.reviki.wiki.renderer;

import java.io.InputStream;

import net.hillsdon.reviki.wiki.MarkupRenderer;
import junit.framework.TestCase;

public class TestRendererRegistry extends TestCase {

  private HtmlRenderer _default;

  private RendererRegistry _registry;

  public void setUp() {
    _default = new HtmlRenderer(null, null, null, null);
    _registry = new RendererRegistry(_default);
  }

  /**
   * Test that we can retrieve the default renderer.
   */
  public void testGetDefault() {
    assertNotNull(_registry.getDefaultRenderer());
    assertEquals(_default, _registry.getDefaultRenderer());
  }

  /**
   * Test that we can insert and retrieve renderers.
   */
  public void testRetrieve() {
    MarkupRenderer<InputStream> renderer = new XSLFORenderer(null);
    String ctype = "xslfo";

    assertFalse(_registry.hasRenderer(ctype));
    _registry.addRenderer(ctype, renderer);
    assertTrue(_registry.hasRenderer(ctype));
    assertEquals(renderer, _registry.getRenderer(ctype));
  }

  /**
   * Test that null ctypes are correctly handled.
   */
  public void testNull() {
    assertFalse(_registry.hasRenderer(null));
    assertNull(_registry.getRenderer(null));
  }
}

Add extra tests for the renderer registry


import java.util.Hashtable;
import java.util.Random;

/**
 * A weight table is used to have keys that contain an ordered set of N strings corresponding to values that are string-
 * integer pairs.
 *
 * [a, b, c, d] -> [(foo, 12), (bar, 7)]
 * [b, c, d, foo] -> [(baz, 1)]
 * [b, c, d, bar] -> [(foobar, 1), (foobaz, 2)];
 * @author Alek Ratzloff
 *
 */
public class Weighttable extends Hashtable<String, Integer> {
	/**
	 * This is to kill the warnings
	 */
	private static final long serialVersionUID = 570882516693488244L;
	private Random random = new Random();

	public Weighttable() {
		super();
	}

	public String getRandomWord() {

		Object[] words = this.keySet().toArray();
		int range = 0;
		for(Object word : words) {
			int weight = this.get(word);
			range += weight;
		}

		int choice = random.nextInt(range);
		int sum = 0;
		for(Object word : words) {
			int weight = this.get(word);
			sum += weight;
			if(sum > choice)
				return (String)word;
		}

		return ".";
	}
}

import java.util.Hashtable;
import java.util.Random;

/**
 * A weight table is used to have keys that contain an ordered set of N strings corresponding to values that are string-
 * integer pairs.
 * @author Alek Ratzloff
 *
 */
public class Weighttable extends Hashtable<String, Integer> {
	/**
	 * This is to kill the warnings
	 */
	private static final long serialVersionUID = 570882516693488244L;
	private Random random = new Random();

	public Weighttable() {
		super();
	}

	public String getRandomWord() {

		Object[] words = this.keySet().toArray();
		int range = 0;
		for(Object word : words) {
			int weight = this.get(word);
			range += weight;
		}

		int choice = random.nextInt(range);
		int sum = 0;
		for(Object word : words) {
			int weight = this.get(word);
			sum += weight;
			if(sum > choice)
				return (String)word;
		}

		return ".";
	}
}

Update documentation in weighttable.java to remove the non-relevant stuff anymore


/**
 * This is the top-level package of the OpenXC library. It contains the
 * primary entry point for applications, the {@link com.openxc.VechicleManager}.
 */
package com.openxc;

/**
 * This is the top-level package of the OpenXC library. It contains the
 * primary entry point for applications, the {@link com.openxc.VehicleManager}.
 */
package com.openxc;

Fix typo in javadocs link.


package org.pdxfinder.repositories;

import org.pdxfinder.dao.Patient;
import org.pdxfinder.dao.PatientSnapshot;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Set;

@Repository
public interface PatientSnapshotRepository extends Neo4jRepository<PatientSnapshot, Long> {

    Set<Patient> findByAge(String sex);

    Set<Patient> findByPatientSex(String sex);

    Patient findByPatientExternalId(String externalId);

    @Query("MATCH (ps:PatientSnapshot)--(p:Patient) WHERE p.externalId = {patientId} RETURN ps")
    Set<PatientSnapshot> findByPatient(@Param("patientId") String patientId);

    @Query("MATCH (mod:ModelCreation)-[ii:IMPLANTED_IN]-(s:Sample)-[sf:SAMPLED_FROM]-(ps:PatientSnapshot)-[pr:PATIENT]-(p:Patient)" +
            "WHERE mod.sourcePdxId = {modelId} " +
            "RETURN mod,ii,s,sf,ps, p, pr")
    PatientSnapshot findByModelId(@Param("modelId") String modelId);

}

package org.pdxfinder.repositories;

import org.pdxfinder.dao.Patient;
import org.pdxfinder.dao.PatientSnapshot;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Set;

@Repository
public interface PatientSnapshotRepository extends Neo4jRepository<PatientSnapshot, Long> {

    Set<Patient> findByAge(String sex);

    Set<Patient> findByPatientSex(String sex);

    Patient findByPatientExternalId(String externalId);

    @Query("MATCH (ps:PatientSnapshot)--(p:Patient) WHERE p.externalId = {patientId} RETURN ps")
    Set<PatientSnapshot> findByPatient(@Param("patientId") String patientId);

    @Query("MATCH (mod:ModelCreation)-[ii:IMPLANTED_IN]-(s:Sample)-[sf:SAMPLED_FROM]-(ps:PatientSnapshot)-[pr:PATIENT]-(p:Patient) \n" +
            "WHERE mod.sourcePdxId = {modelId}\n" +
            "WITH mod, ii, s, sf, ps, pr, p\n" +
            "OPTIONAL MATCH (s)-[ot:ORIGIN_TISSUE]-(t1:Tissue)\n" +
            "OPTIONAL MATCH (s)-[ss:SAMPLE_SITE]-(t2:Tissue)\n" +
            "\n" +
            "RETURN mod,ii,s,sf,ps, p, pr, t1, t2, ot, ss")
    PatientSnapshot findByModelId(@Param("modelId") String modelId);

}

Update query with additional nodes


package no.nordicsemi.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import org.droidparts.persist.sql.AbstractDBOpenHelper;

public class DBOpenHelper extends AbstractDBOpenHelper {

    private static final String DB_FILE = "Evere.sql";
    private static final int DB_VERSION = 1;

    public DBOpenHelper(Context ctx) {
        super(ctx, DB_FILE, DB_VERSION);
    }

    @Override
    protected void onCreateTables(SQLiteDatabase sqLiteDatabase) {
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        /* TODO: add migration */
        dropTables(db);
        onCreate(db);
    }
}

package no.nordicsemi.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import org.droidparts.persist.sql.AbstractDBOpenHelper;

import no.nordicsemi.models.LocationPuck;

public class DBOpenHelper extends AbstractDBOpenHelper {

    private static final String DB_FILE = "Evere.sql";
    private static final int DB_VERSION = 1;

    public DBOpenHelper(Context ctx) {
        super(ctx, DB_FILE, DB_VERSION);
    }

    @Override
    protected void onCreateTables(SQLiteDatabase sqLiteDatabase) {
        createTables(sqLiteDatabase, LocationPuck.class);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        /* TODO: add migration */
        dropTables(db);
        onCreate(db);
    }
}

Create database table for Location Pucks


package com.nigorojr.typebest;

import java.sql.SQLException;
import java.util.HashMap;

public class Tester {

    public static void main(String[] args) {
        // This is to test the behavior of the Database class
        try {
            Records rec = new Records();
            System.out.println("exist?\n" + rec.isTableExist());
            HashMap<String, String> pair = new HashMap<String, String>();
            pair.put("foo", "int");
            pair.put("hoge", "varchar(50)");
            if (!rec.isTableExist()) {
                rec.createTable(pair);
            }
        }
        catch (SQLException e) {
            e.printStackTrace();
        }
    }

}

package com.nigorojr.typebest;

import java.sql.SQLException;
import java.util.HashMap;

public class Tester {

    public static void main(String[] args) {
        // This is to test the behavior of the Database class
        try {
            Records rec = new Records();
            System.out.println("exist?\n" + rec.isTableExist());
            HashMap<String, String> pair = new HashMap<String, String>();
            pair.put("foo", "int");
            pair.put("hoge", "varchar(50)");
            if (!rec.isTableExist()) {
                rec.createTable(pair);
            }
            System.out.println("finished creating...");
            HashMap<String, String> ins = new HashMap<String, String>();
            ins.put("foo", "50");
            ins.put("hoge", "'barbar'");
            rec.insert(ins);
        }
        catch (SQLException e) {
            e.printStackTrace();
        }
    }

}

Add test for checking whether insert method runs or not


package net.teamio.taam.content.common;

import net.minecraftforge.fluids.Fluid;

public class FluidDye extends Fluid {

	public FluidDye(String fluidName) {
		super(fluidName, null, null);//TODO: ResourceLocations
		setViscosity(400);
		setDensity(1300);
	}

}

package net.teamio.taam.content.common;

import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;

public class FluidDye extends Fluid {

	public FluidDye(String fluidName) {
		super(fluidName, new ResourceLocation("taam", "dye"), new ResourceLocation("taam", "dye"));//TODO: ResourceLocations
		setViscosity(400);
		setDensity(1300);
	}

}

Fix a crash with fluid dyes


package com.mapzen.tangram;

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

/**
 * {@code TouchLabel} represents labels that can be selected on the scree
 */
public class TouchLabel {

    /**
     * Options for the type of TouchLabel
     */
    public enum LabelType {
        POINT,
        TEXT,
    }

    private List<LngLat> coordinates;
    private LabelType type;

    public TouchLabel(double[] coordinates, int type) {
        this.coordinates = new ArrayList<>();

        for (int i = 0; i < coordinates.length - 1; i += 2) {
            this.coordinates.add(new LngLat(coordinates[i], coordinates[i + 1]));
        }

        this.type = LabelType.values()[type];
    }

    public LabelType getType() {
        return this.type;
    }

    public List<LngLat> getCoordinates() {
        return this.coordinates;
    }
}

package com.mapzen.tangram;

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

/**
 * {@code TouchLabel} represents labels that can be selected on the screen
 */
public class TouchLabel {

    /**
     * Options for the type of TouchLabel
     */
    public enum LabelType {
        ICON,
        TEXT,
    }

    private List<LngLat> coordinates;
    private LabelType type;

    public TouchLabel(double[] coordinates, int type) {
        this.coordinates = new ArrayList<>();

        for (int i = 0; i < coordinates.length - 1; i += 2) {
            this.coordinates.add(new LngLat(coordinates[i], coordinates[i + 1]));
        }

        this.type = LabelType.values()[type];
    }

    public LabelType getType() {
        return this.type;
    }

    public List<LngLat> getCoordinates() {
        return this.coordinates;
    }
}

Use same defines as c++ interface in java code


public class Solution {

    public char findTheDifference(String s, String t) {

        char addedChar = 0;

        for (int i = 0; i < s.length(); ++i) {
            addedChar ^= s.charAt(i);
        }

        for (int i = 0; i < t.length(); ++i) {
            addedChar ^= t.charAt(i);
        }

        return addedChar;

    }

}

public class Solution {

    public char findTheDifference(String s, String t) {

        char addedChar = 0;

        for (int i = 0; i < s.length(); i++) {
            addedChar ^= s.charAt(i);
        }

        for (int i = 0; i < t.length(); i++) {
            addedChar ^= t.charAt(i);
        }

        return addedChar;

    }

}

Create : 389 Find the Difference


package com.aayaffe.sailingracecoursemanager.communication;

import java.io.Serializable;

/**
 * Created by aayaffe on 30/09/2015.
 */
public enum ObjectTypes {
    WorkerBoat,
    FlagBuoy,
    TomatoBuoy,
    TriangleBuoy,
    StartLine,
    FinishLine,
    StartFinishLine,

    RaceManager,  //from here, the relevant ObjectTypes:
    Buoy,
    Gate,
    Satellite,
    ReferencePoint,
    Other
}

package com.aayaffe.sailingracecoursemanager.communication;

import java.io.Serializable;

/**
 * Created by aayaffe on 30/09/2015.
 */
public enum ObjectTypes {
    RaceManager(0),
    WorkerBoat(1),
    Buoy(2),
    FlagBuoy(3),
    TomatoBuoy(4),
    TriangleBuoy(5),
    StartLine(6),
    FinishLine(7),
    StartFinishLine(8),
    Gate(9),
    ReferencePoint(10),
    Other(11);

    private int value;

    ObjectTypes(int value) {
        this.value = value;
    }

    public int getValue() {
        return value;
    }
}

Revert "Revert "Updated object types in Dev""


package jp.wasabeef.recyclerview.internal;

import android.support.v4.view.ViewCompat;
import android.view.View;

/**
 * Copyright (C) 2015 Wasabeef
 *
 * 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.
 */

public final class ViewHelper {

  public static void clear(View v) {
    ViewCompat.setAlpha(v, 1);
    ViewCompat.setScaleY(v, 1);
    ViewCompat.setScaleX(v, 1);
    ViewCompat.setTranslationY(v, 0);
    ViewCompat.setTranslationX(v, 0);
    ViewCompat.setRotation(v, 0);
    ViewCompat.setRotationY(v, 0);
    ViewCompat.setRotationX(v, 0);
    ViewCompat.setPivotY(v, v.getMeasuredHeight() / 2);
    ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2);
    ViewCompat.animate(v).setInterpolator(null);
  }
}

package jp.wasabeef.recyclerview.internal;

import android.support.v4.view.ViewCompat;
import android.view.View;

/**
 * Copyright (C) 2015 Wasabeef
 *
 * 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.
 */

public final class ViewHelper {

  public static void clear(View v) {
    ViewCompat.setAlpha(v, 1);
    ViewCompat.setScaleY(v, 1);
    ViewCompat.setScaleX(v, 1);
    ViewCompat.setTranslationY(v, 0);
    ViewCompat.setTranslationX(v, 0);
    ViewCompat.setRotation(v, 0);
    ViewCompat.setRotationY(v, 0);
    ViewCompat.setRotationX(v, 0);
    ViewCompat.setPivotY(v, v.getMeasuredHeight() / 2);
    ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2);
    ViewCompat.animate(v)
            .setInterpolator(null)
            .setStartDelay(0);
  }
}

Fix setStartDelay() is not reset by clear()


package de.cdietze.ld37.core;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class MathUtils {

  public static List<Integer> shuffledRange(int size, Random random) {
    ArrayList<Integer> list = new ArrayList<>(size);
    for (int i = 0; i < size; ++i) list.add(i);
    Collections.shuffle(list, random);
    return list;
  }
}

package de.cdietze.ld37.core;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class MathUtils {

  public static List<Integer> shuffledRange(int size, Random random) {
    ArrayList<Integer> list = new ArrayList<>(size);
    for (int i = 0; i < size; ++i) list.add(i);
    shuffle(list, random);
    return list;
  }

  /** GWT does not emulate {@link java.util.Collections#shuffle(List, Random)} */
  public static void shuffle(List<?> list, Random random) {
    for (int index = 0; index < list.size(); index += 1) {
      Collections.swap(list, index, index + random.nextInt(list.size() - index));
    }
  }
}

Fix for GWT’s missing collections.shuffle


package edu.northwestern.bioinformatics.studycalendar.testing;

import junit.framework.TestCase;

import java.lang.reflect.Method;
import java.util.Set;
import java.util.HashSet;

import org.easymock.classextension.EasyMock;

/**
 * @author Rhett Sutphin
 */
public abstract class StudyCalendarTestCase extends TestCase {
    protected Set<Object> mocks = new HashSet<Object>();

    ////// MOCK REGISTRATION AND HANDLING

    protected <T> T registerMockFor(Class<T> forClass) {
        return registered(EasyMock.createMock(forClass));
    }

    protected <T> T registerMockFor(Class<T> forClass, Method[] methodsToMock) {
        return registered(EasyMock.createMock(forClass, methodsToMock));
    }

    protected void replayMocks() {
        for (Object mock : mocks) EasyMock.replay(mock);
    }

    protected void verifyMocks() {
        for (Object mock : mocks) EasyMock.verify(mock);
    }

    protected void resetMocks() {
        for (Object mock : mocks) EasyMock.reset(mock);
    }

    private <T> T registered(T mock) {
        mocks.add(mock);
        return mock;
    }
}

package edu.northwestern.bioinformatics.studycalendar.testing;

import edu.nwu.bioinformatics.commons.testing.CoreTestCase;

import junit.framework.TestCase;

import java.lang.reflect.Method;
import java.util.Set;
import java.util.HashSet;

import org.easymock.classextension.EasyMock;

/**
 * @author Rhett Sutphin
 */
public abstract class StudyCalendarTestCase extends CoreTestCase {
    protected Set<Object> mocks = new HashSet<Object>();

    ////// MOCK REGISTRATION AND HANDLING

    protected <T> T registerMockFor(Class<T> forClass) {
        return registered(EasyMock.createMock(forClass));
    }

    protected <T> T registerMockFor(Class<T> forClass, Method[] methodsToMock) {
        return registered(EasyMock.createMock(forClass, methodsToMock));
    }

    protected void replayMocks() {
        for (Object mock : mocks) EasyMock.replay(mock);
    }

    protected void verifyMocks() {
        for (Object mock : mocks) EasyMock.verify(mock);
    }

    protected void resetMocks() {
        for (Object mock : mocks) EasyMock.reset(mock);
    }

    private <T> T registered(T mock) {
        mocks.add(mock);
        return mock;
    }
}

Extend CoreTestCase for access to assertPositve/Negative, others


package com.yahoo.vespa.hosted.node.admin.task.util.network;

/**
 * Strong type IPv4 and IPv6 with the respective iptables executable.
 *
 * @author smorgrav
 */
enum IPVersion {

    IPv6("ip6tables"),
    IPv4("iptables");

    IPVersion(String exec) {
        this.exec = exec;
    }

    private String exec;

    String exec() {
        return exec;
    }
}

package com.yahoo.vespa.hosted.node.admin.task.util.network;

/**
 * Strong type IPv4 and IPv6 with the respective iptables executable.
 *
 * @author smorgrav
 */
public enum IPVersion {

    IPv6("ip6tables"),
    IPv4("iptables");

    IPVersion(String exec) {
        this.exec = exec;
    }

    private String exec;

    String exec() {
        return exec;
    }
}

Make public to be able to use IPAddress class in other packages