// Copyright (C) 2013 The Android Open Source Project
//
// 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.googlesource.gerrit.plugins.cookbook;

import java.util.List;

import com.google.common.collect.Lists;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.extensions.webui.TopMenu;
import com.google.inject.Inject;

public class HelloTopMenu implements TopMenu {
  private final List<MenuEntry> menuEntries;

  @Inject
  public HelloTopMenu(@PluginName String pluginName) {
    String baseUrl = "/plugins/" + pluginName + "/";
    List<MenuItem> menuItems = Lists.newArrayListWithCapacity(1);
    menuItems.add(new MenuItem("Documentation", baseUrl));
    menuEntries = Lists.newArrayListWithCapacity(1);
    menuEntries.add(new MenuEntry("Cookbook", menuItems));
  }

  @Override
  public List<MenuEntry> getEntries() {
      return menuEntries;
  }
}

// Copyright (C) 2013 The Android Open Source Project
//
// 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.googlesource.gerrit.plugins.cookbook;

import java.util.List;

import com.google.common.collect.Lists;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.extensions.webui.TopMenu;
import com.google.inject.Inject;

public class HelloTopMenu implements TopMenu {
  private final List<MenuEntry> menuEntries;

  @Inject
  public HelloTopMenu(@PluginName String pluginName) {
    String baseUrl = "/plugins/" + pluginName + "/";
    List<MenuItem> menuItems = Lists.newArrayListWithCapacity(1);
    menuItems.add(new MenuItem("Documentation", baseUrl));
    menuEntries = Lists.newArrayListWithCapacity(1);
    menuEntries.add(new MenuEntry("Cookbook", menuItems));
    menuEntries.add(new MenuEntry("Projects", Lists.newArrayList(
        new MenuItem("Browse Repositories", "https://gerrit.googlesource.com/"))));
  }

  @Override
  public List<MenuEntry> getEntries() {
      return menuEntries;
  }
}

Add example of extending Gerrit's top menu item

Add a "Browse Repositories" item in the "Projects" menu.

Change-Id: I67af5bca1a14288147b1bc43fb089ba0abe0d6b2


/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package net.java.sip.communicator.impl.gui.lookandfeel;

import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;

/**
 * @author Yana Stamcheva
 */
public class SIPCommMenuBarUI
    extends BasicMenuBarUI
{
    /**
     * Creates a new SIPCommMenuUI instance.
     */
    public static ComponentUI createUI(JComponent x)
    {
        return new SIPCommMenuBarUI();
    }

    protected void installDefaults()
    {
        super.installDefaults();

        LookAndFeel.installProperty(menuBar, "opaque", Boolean.FALSE);
        LookAndFeel.installBorder(menuBar, null);
    }
}

/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package net.java.sip.communicator.impl.gui.lookandfeel;

import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;

/**
 * @author Yana Stamcheva
 */
public class SIPCommMenuBarUI
    extends BasicMenuBarUI
{
    /**
     * Creates a new SIPCommMenuUI instance.
     */
    public static ComponentUI createUI(JComponent x)
    {
        return new SIPCommMenuBarUI();
    }

    protected void installDefaults()
    {
        super.installDefaults();

        LookAndFeel.installProperty(menuBar, "opaque", Boolean.FALSE);
    }
}

Fix NullPointerException when starting SC.


package hudson.plugins.ec2.win.winrm.request;

import org.dom4j.Document;

public interface WinRMRequest {
    public Document build();
}

package hudson.plugins.ec2.win.winrm.request;

import org.dom4j.Document;

public interface WinRMRequest {
    Document build();
}

Remove redundant public modifier on interface method

Interface methods are per default public.


/**
 * 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.repository.management.model;

/**
 * @author Titouan COMPIEGNE (titouan.compiegne at gravitee.io)
 * @author David BRASSELY (brasseld at gmail.com)
 * @author GraviteeSource Team
 */
public enum EventType {

    PUBLISH_API,
    PUBLISH_API_RESULT,
    UNPUBLISH_API,
    UNPUBLISH_API_RESULT,
    START_API,
    STOP_API,
    START_GATEWAY,
    STOP_GATEWAY
}

/**
 * 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.repository.management.model;

/**
 * @author Titouan COMPIEGNE (titouan.compiegne at gravitee.io)
 * @author David BRASSELY (brasseld at gmail.com)
 * @author GraviteeSource Team
 */
public enum EventType {

    PUBLISH_API,
    PUBLISH_API_RESULT,
    UNPUBLISH_API,
    UNPUBLISH_API_RESULT,
    START_API,
    STOP_API,
    GATEWAY_STARTED,
    GATEWAY_STOPPED
}

Rename events relative to the gateway

feat(instance): Rename events relative to the gateway


package hu.kazocsaba.math.geometry.fitting;

import hu.kazocsaba.math.matrix.Vector2;
import java.util.List;
import hu.kazocsaba.math.geometry.Line2;
import hu.kazocsaba.math.matrix.immutable.ImmutableMatrixFactory;
import java.util.ArrayList;
import java.util.Random;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Kazó Csaba
 */
public class LineFitterTest {
	private static final double EPS=1e-8;

	@Test
	public void testFit() {
		Line2 refLine=Line2.createFromDir(ImmutableMatrixFactory.createVector(3, 4), ImmutableMatrixFactory.createVector(-5, 2));

		Random rnd=new Random(726);

		List<Vector2> points=new ArrayList<Vector2>(50);
		for (int i=0; i<50; i++) points.add(refLine.getPointAt(rnd.nextDouble()));

		Line2 fitLine=LineFitter.fit2(points);

		assertEquals(1, Math.abs(refLine.getUnitDir().dot(fitLine.getUnitDir())), EPS);
		assertEquals(0, refLine.distance(fitLine.getPoint()), EPS);
	}
}

package hu.kazocsaba.math.geometry.fitting;

import hu.kazocsaba.math.geometry.DegenerateCaseException;
import hu.kazocsaba.math.matrix.Vector2;
import java.util.List;
import hu.kazocsaba.math.geometry.Line2;
import hu.kazocsaba.math.matrix.MatrixFactory;
import hu.kazocsaba.math.matrix.immutable.ImmutableMatrixFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Kazó Csaba
 */
public class LineFitterTest {
	private static final double EPS=1e-8;

	@Test
	public void testFit() {
		Line2 refLine=Line2.createFromDir(ImmutableMatrixFactory.createVector(3, 4), ImmutableMatrixFactory.createVector(-5, 2));

		Random rnd=new Random(726);

		List<Vector2> points=new ArrayList<Vector2>(50);
		for (int i=0; i<50; i++) points.add(refLine.getPointAt(rnd.nextDouble()));

		Line2 fitLine=LineFitter.fit2(points);

		assertEquals(1, Math.abs(refLine.getUnitDir().dot(fitLine.getUnitDir())), EPS);
		assertEquals(0, refLine.distance(fitLine.getPoint()), EPS);
	}

	@Test(expected=DegenerateCaseException.class)
	public void testDegenerate() {
		LineFitter.fit2(Collections.nCopies(10, MatrixFactory.createVector(2, -4)));
	}
}

Add test for degenerate line fitter task.


package seedu.ezdo.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.ezdo.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!";
    public static final String MESSAGE_WRONG_LIST = "Please return to the task list if you want to mark a task as done.";

}

Add punctuation to messages to improve consistency


package com.epam.ta.reportportal.ws.model.dashboard;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * @author Pavel Bortnik
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AddWidgetRq {

	@Valid
	@NotNull
	@JsonProperty(value = "addWidget")
	private DashboardResource.WidgetObjectModel objectModel;

	public DashboardResource.WidgetObjectModel getObjectModel() {
		return objectModel;
	}

	public void setObjectModel(DashboardResource.WidgetObjectModel objectModel) {
		this.objectModel = objectModel;
	}
}

package com.epam.ta.reportportal.ws.model.dashboard;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * @author Pavel Bortnik
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AddWidgetRq {

	@Valid
	@NotNull
	@JsonProperty(value = "addWidget")
	private DashboardResource.WidgetObjectModel addWidget;

	@NotNull
	public DashboardResource.WidgetObjectModel getAddWidget() {
		return addWidget;
	}

	public void setAddWidget(@NotNull DashboardResource.WidgetObjectModel addWidget) {
		this.addWidget = addWidget;
	}
}

Add widget property has been renamed

Add widget property has been renamed


package com.thinksincode.tailstreamer.controller;

import com.thinksincode.tailstreamer.FileTailService;
import com.thinksincode.tailstreamer.TailStreamer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class MainController {

    @Autowired
    private FileTailService fileTailService;

    @RequestMapping("/")
    public String index(Model model) {
        model.addAttribute("file", fileTailService.getFileName());
        model.addAttribute("filePath", fileTailService.getFilePath());
        model.addAttribute("version", TailStreamer.VERSION);
        return "index";
    }
}

package com.thinksincode.tailstreamer.controller;

import com.thinksincode.tailstreamer.FileTailService;
import com.thinksincode.tailstreamer.TailStreamer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class MainController {

    /** The maximum filename length before truncation occurs. */
    private static final int MAX_FILENAME_LENGTH = 50;

    @Autowired
    private FileTailService fileTailService;

    @RequestMapping("/")
    public String index(Model model) {
        model.addAttribute("file", maybeTruncate(fileTailService.getFileName()));
        model.addAttribute("filePath", fileTailService.getFilePath());
        model.addAttribute("version", TailStreamer.VERSION);
        return "index";
    }

    private String maybeTruncate(String fileName) {
        if (fileName.length() <= MAX_FILENAME_LENGTH) {
            return fileName;
        } else {
            String extension = fileName.substring(fileName.lastIndexOf('.'));
            return fileName.substring(0, MAX_FILENAME_LENGTH) + "..." + fileName.substring(fileName.length() - extension.length() - 1);
        }
    }
}

Truncate filename if it exceeds 50 characters


/*
 * 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.btisystems.pronx.ems.core.model;

import com.btisystems.pronx.ems.core.snmp.IVariableBindingHandler;

/**
 * Manages the creation and population of entities for a discovered device.
 */
public interface INetworkDevice extends IVariableBindingHandler {

    /**
     * @return  the root entity containing the tree of managed objects
     */
    AbstractRootEntity getRootObject();
}

/*
 * 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.btisystems.pronx.ems.core.model;

import com.btisystems.pronx.ems.core.snmp.IVariableBindingHandler;
import java.io.Serializable;

/**
 * Manages the creation and population of entities for a discovered device.
 */
public interface INetworkDevice extends IVariableBindingHandler, Serializable {

    /**
     * @return  the root entity containing the tree of managed objects
     */
    AbstractRootEntity getRootObject();
}

Make NetworkDevice serializable to help with potential cache implementations.


package org.apache.hadoop.hbase.client;

/**
 * Abstract class necessary to access protected parameters
 */
public abstract class AbstractHbaseClient {
  protected final String clusterId;

  /**
   * Constructor
   *
   * @param connection to use for connection
   */
  public AbstractHbaseClient(HConnection connection) {
    this.clusterId = ((HConnectionManager.HConnectionImplementation) connection).clusterId;
  }
}

package org.apache.hadoop.hbase.client;

/**
 * Abstract class necessary to access protected parameters
 */
public abstract class AbstractHbaseClient {
  protected final String clusterId;
  private final HConnection connection;

  /**
   * Constructor
   *
   * @param connection to use for connection
   */
  public AbstractHbaseClient(HConnection connection) {
    this.connection = connection;
    this.clusterId = ((HConnectionManager.HConnectionImplementation) connection).clusterId;
  }

  /**
   * Get HConnection to talk to master/cluster
   *
   * @return HConnection
   */
  public HConnection getConnection() {
    return connection;
  }
}

Add method to get Connection from HbaseClient


package com.srs.tetris.bob.evaluator;

import com.srs.tetris.bob.Position;
import com.srs.tetris.game.BitBoard;

/**
 * Gives a high
 */
public class DangerZoneEvaluator implements PositionEvaluator {
	private int dangerZoneSize;
	private double exponent;

	public DangerZoneEvaluator(int dangerZoneSize, double exponent) {
		this.dangerZoneSize = dangerZoneSize;
		this.exponent = exponent;
	}

	@Override
	public Score evaluate(Position position) {
		BitBoard board = position.getBoard();
		int height = 0;

		for (int y = 0; y < dangerZoneSize; y++) {
			if (!board.isLineEmpty(y)) {
				height = dangerZoneSize - y;
				break;
			}
		}

		return new ScalarScore(Math.pow(height, exponent));
	}
}

package com.srs.tetris.bob.evaluator;

import com.srs.tetris.bob.Position;
import com.srs.tetris.game.BitBoard;

/**
 * Gives a high
 */
public class DangerZoneEvaluator implements PositionEvaluator {
	private int dangerZoneSize;
	private double exponent;

	public DangerZoneEvaluator(int dangerZoneSize, double exponent) {
		this.dangerZoneSize = dangerZoneSize;
		this.exponent = exponent;
	}

	@Override
	public Score evaluate(Position position) {
		BitBoard board = position.getBoard();
		int height = 0;
		int dangerZoneSize = Math.min(board.getHeight(), this.dangerZoneSize);

		for (int y = 0; y < dangerZoneSize; y++) {
			if (!board.isLineEmpty(y)) {
				height = dangerZoneSize - y;
				break;
			}
		}

		return new ScalarScore(Math.pow(height, exponent));
	}
}

Fix out of bounds exception when danger zone is larger than the board


package org.skyscreamer.yoga.selector;

import java.util.Set;

public abstract class AbstractSelectable implements Selectable
{
    private Set<SelectorField> _selectorFields;

    public AbstractSelectable( Selector selector )
    {
        _selectorFields = selector.getFields();
    }

    public Set<SelectorField> getSelectorFields()
    {
        return _selectorFields;
    }
}

package org.skyscreamer.yoga.selector;

import java.util.Collections;
import java.util.Set;

public abstract class AbstractSelectable implements Selectable
{
    private Set<SelectorField> _selectorFields;

    public AbstractSelectable() {}

    public AbstractSelectable( Selector selector )
    {
        setSelector( selector );
    }

    public Set<SelectorField> getSelectorFields()
    {
        return _selectorFields;
    }

    public void setSelector( Selector selector ) {
        _selectorFields = selector != null ? selector.getFields() : Collections.<SelectorField>emptySet();
    }
}

Allow selector to be set after construction


package com.lloydtorres.stately.dto;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by Lloyd on 2016-01-28.
 * An object containing text for one of the options in an issue.
 */
public class IssueOption implements Parcelable {
    public static final String QUERY = "https://www.nationstates.net/page=show_dilemma/dilemma=%d/template-overall=none";
    public static final String POST_QUERY = "https://www.nationstates.net/page=enact_dilemma/dilemma=%d/template-overall=none";
    public static final String SELECTED_HEADER = "selected";
    public static final String DISMISS_HEADER = "choice--1";

    public int index;
    public String content;
    public String header;

    public IssueOption() { super(); }

    protected IssueOption(Parcel in) {
        index = in.readInt();
        content = in.readString();
        header = in.readString();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(index);
        dest.writeString(content);
        dest.writeString(header);
    }

    @SuppressWarnings("unused")
    public static final Parcelable.Creator<IssueOption> CREATOR = new Parcelable.Creator<IssueOption>() {
        @Override
        public IssueOption createFromParcel(Parcel in) {
            return new IssueOption(in);
        }

        @Override
        public IssueOption[] newArray(int size) {
            return new IssueOption[size];
        }
    };
}

package com.lloydtorres.stately.dto;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by Lloyd on 2016-01-28.
 * An object containing text for one of the options in an issue.
 */
public class IssueOption implements Parcelable {
    public static final String QUERY = "https://www.nationstates.net/page=show_dilemma/dilemma=%d/template-overall=none";
    public static final String POST_QUERY = "https://www.nationstates.net/page=enact_dilemma/dilemma=%d";
    public static final String SELECTED_HEADER = "selected";
    public static final String DISMISS_HEADER = "choice--1";

    public int index;
    public String content;
    public String header;

    public IssueOption() { super(); }

    protected IssueOption(Parcel in) {
        index = in.readInt();
        content = in.readString();
        header = in.readString();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(index);
        dest.writeString(content);
        dest.writeString(header);
    }

    @SuppressWarnings("unused")
    public static final Parcelable.Creator<IssueOption> CREATOR = new Parcelable.Creator<IssueOption>() {
        @Override
        public IssueOption createFromParcel(Parcel in) {
            return new IssueOption(in);
        }

        @Override
        public IssueOption[] newArray(int size) {
            return new IssueOption[size];
        }
    };
}

Revert "Add query response minimizer parameter back"

This reverts commit ead7b0d5c99c2e3d9ae14310af8f16bf56bf2a70.


package org.zstack.header.storage.primary;

import org.zstack.header.message.NeedReplyMessage;
import org.zstack.header.storage.snapshot.VolumeSnapshotStruct;

/**
 */
public class TakeSnapshotMsg extends NeedReplyMessage implements PrimaryStorageMessage {
    private String primaryStorageUuid;
    private VolumeSnapshotStruct struct;

    @Override
    public String getPrimaryStorageUuid() {
        return primaryStorageUuid;
    }

    public void setPrimaryStorageUuid(String primaryStorageUuid) {
        this.primaryStorageUuid = primaryStorageUuid;
    }

    public VolumeSnapshotStruct getStruct() {
        return struct;
    }

    public void setStruct(VolumeSnapshotStruct struct) {
        this.struct = struct;
    }
}

package org.zstack.header.storage.primary;

import org.zstack.header.core.ApiTimeout;
import org.zstack.header.message.NeedReplyMessage;
import org.zstack.header.storage.snapshot.VolumeSnapshotStruct;
import org.zstack.header.volume.APICreateVolumeSnapshotMsg;

/**
 */
@ApiTimeout(apiClasses = {APICreateVolumeSnapshotMsg.class})
public class TakeSnapshotMsg extends NeedReplyMessage implements PrimaryStorageMessage {
    private String primaryStorageUuid;
    private VolumeSnapshotStruct struct;

    @Override
    public String getPrimaryStorageUuid() {
        return primaryStorageUuid;
    }

    public void setPrimaryStorageUuid(String primaryStorageUuid) {
        this.primaryStorageUuid = primaryStorageUuid;
    }

    public VolumeSnapshotStruct getStruct() {
        return struct;
    }

    public void setStruct(VolumeSnapshotStruct struct) {
        this.struct = struct;
    }
}

Add a missing timeout decoration

Add a missing timeout decoration

Signed-off-by: David Lee <15c338f3b79a63a0d5423e9c6562cd312918fe74@gmail.com>


package cgeo.geocaching;

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

public class cgSearch {
	private Long id = null;
	private List<String> geocodes = new ArrayList<String>();

	public String error = null;
	public String url = "";
	public String[] viewstates = null;
	public int totalCnt = 0;

	public cgSearch() {
		id = System.currentTimeMillis(); // possible collisions here - not guaranteed to be unique
	}

	public Long getCurrentId() {
		return id;
	}

	public List<String> getGeocodes() {
		return geocodes;
	}

	public int getCount() {
		return geocodes.size();
	}

	public void addGeocode(String geocode) {
		if (geocodes == null) {
			geocodes = new ArrayList<String>();
		}

		geocodes.add(geocode);
	}
}

package cgeo.geocaching;

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

public class cgSearch {
	private long id;
	private List<String> geocodes = new ArrayList<String>();

	public String error = null;
	public String url = "";
	public String[] viewstates = null;
	public int totalCnt = 0;

	public cgSearch() {
		id = System.currentTimeMillis(); // possible collisions here - not guaranteed to be unique
	}

	public long getCurrentId() {
		return id;
	}

	public List<String> getGeocodes() {
		return geocodes;
	}

	public int getCount() {
		return geocodes.size();
	}

	public void addGeocode(String geocode) {
		if (geocodes == null) {
			geocodes = new ArrayList<String>();
		}

		geocodes.add(geocode);
	}
}

Use long instead of Long when appropriate


package leetcode;

/**
 * https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
 */
public class Problem121 {
    public int maxProfit(int[] prices) {
        return 0;
    }

    public static void main(String[] args) {
        Problem121 prob = new Problem121();
        System.out.println(prob.maxProfit(new int[]{1, 2, 4, 2, 1, 3}));
    }
}

package leetcode;

/**
 * https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
 */
public class Problem121 {
    public int maxProfit(int[] prices) {
        int[] max = new int[prices.length];
        int m = -1;
        for (int i = prices.length-1; i != 0; i--) {
            max[i] = Math.max(m, prices[i]);
            m = max[i];
        }
        int profit = 0;
        for (int i = 0; i < prices.length-1; i++) {
            int buy = prices[i];
            int sell = max[i+1];
            profit = Math.max(profit, sell-buy);
        }
        return profit;
    }

    public static void main(String[] args) {
        Problem121 prob = new Problem121();
        System.out.println(prob.maxProfit(new int[]{1, 2, 4, 2, 1, 3}));
        System.out.println(prob.maxProfit(new int[]{3, 2, 6, 5, 0, 3}));
    }
}

Update problem 121 (not verified)

Update problem 121 (not verified)


/**
 *
 */
package org.traccar;

import org.traccar.helper.DistanceCalculator;
import org.traccar.helper.Log;
import org.traccar.model.Position;

/**
 * <p>
 * Odometer - total mileage calculation handler
 * </p>
 *
 * @author Amila Silva
 *
 */
public class OdometerHandler extends BaseDataHandler {

    public OdometerHandler() {
        Log.debug("System based odometer calculation enabled for all devices");
    }

    private Position getLastPosition(long deviceId) {
        if (Context.getConnectionManager() != null) {
            return Context.getConnectionManager().getLastPosition(deviceId);
        }
        return null;
    }

    private Position calculateDistance(Position position) {
        Position last = getLastPosition(position.getDeviceId());
        if (last != null) {
            double distance = DistanceCalculator.distance(
                    position.getLatitude(), position.getLongitude(),
                    last.getLatitude(), last.getLongitude());
            distance = Math.round((distance) * 100.0) / 100.0;
            double odometer = distance + last.getOdometer();
            position.setOdometer(odometer);
        }
        return position;
    }

    @Override
    protected Position handlePosition(Position position) {
        return calculateDistance(position);
    }

}

/**
 *
 */
package org.traccar;

import org.traccar.helper.DistanceCalculator;
import org.traccar.helper.Log;
import org.traccar.model.Position;

/**
 * <p>
 * Odometer - total mileage calculation handler
 * </p>
 *
 * @author Amila Silva
 *
 */
public class OdometerHandler extends BaseDataHandler {

    public OdometerHandler() {
        Log.debug("System based odometer calculation enabled for all devices");
    }

    private Position getLastPosition(long deviceId) {
        if (Context.getConnectionManager() != null) {
            return Context.getConnectionManager().getLastPosition(deviceId);
        }
        return null;
    }

    private Position calculateDistance(Position position) {
        Position last = getLastPosition(position.getDeviceId());
        if (last != null) {
            // set odometer only on movement
            double odometer = 0.0;
            if (last.getSpeed() == 0 && position.getSpeed() == 0) {
                odometer = last.getOdometer();
            } else {
                double distance = DistanceCalculator.distance(
                        position.getLatitude(), position.getLongitude(),
                        last.getLatitude(), last.getLongitude());
                distance = Math.round((distance) * 100.0) / 100.0;
                odometer = distance + last.getOdometer();
            }
            position.setOdometer(odometer);
        }
        return position;
    }

    @Override
    protected Position handlePosition(Position position) {
        return calculateDistance(position);
    }

}

Set Odometer only if there is a movement


package com.corwinjv.mobtotems.blocks.tiles.TotemLogic;

import net.minecraft.item.ItemStack;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by CorwinJV on 1/25/2017.
 */
public class WolfLogic extends TotemLogic {
    @Override
    public List<ItemStack> getCost() {
        List<ItemStack> cost = new ArrayList<>();
        return cost;
    }

    @Nonnull
    @Override
    public EffectType getEffectType() {
        return EffectType.EFFECT;
    }
}

package com.corwinjv.mobtotems.blocks.tiles.TotemLogic;

import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by CorwinJV on 1/25/2017.
 */
public class WolfLogic extends TotemLogic {
    @Override
    public List<ItemStack> getCost() {
        List<ItemStack> cost = new ArrayList<>();
        cost.add(new ItemStack(Items.BONE, 4, 0));
        return cost;
    }

    @Nonnull
    @Override
    public EffectType getEffectType() {
        return EffectType.EFFECT;
    }
}

Add cost to wolf totem

Add cost to wolf totem


package com.mercateo.common.rest.schemagen;

import com.mercateo.common.rest.schemagen.generictype.GenericType;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Map;

public final class PropertySubTypeMapper {

    private PropertySubTypeMapper() {
    }

    public static PropertySubType of(GenericType<?> type, PropertyType propertyType) {
        switch (propertyType) {
            case OBJECT:
                final Class<?> clazz = type.getRawType();
                if (Map.class.isAssignableFrom(clazz)) {
                    final ParameterizedType parameterizedType = (ParameterizedType) type.getType();
                    final Type type1 = parameterizedType.getActualTypeArguments()[0];
                    if (type1 instanceof Class && Enum.class.isAssignableFrom((Class) type1)) {
                        return PropertySubType.DICT;
                    }
                }
                break;
        }
        return PropertySubType.NONE;
    }
}

package com.mercateo.common.rest.schemagen;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Map;

import com.mercateo.common.rest.schemagen.generictype.GenericType;

public final class PropertySubTypeMapper {

    private PropertySubTypeMapper() {
    }

    public static PropertySubType of(GenericType<?> type, PropertyType propertyType) {
        switch (propertyType) {
            case OBJECT:
                final Class<?> clazz = type.getRawType();
                if (Map.class.isAssignableFrom(clazz)) {
                    final ParameterizedType parameterizedType = (ParameterizedType) type.getType();
                    final Type type1 = parameterizedType.getActualTypeArguments()[0];
                    if (type1 instanceof Class && Enum.class.isAssignableFrom((Class) type1)) {
                        return PropertySubType.DICT;
                    }
                }
                break;
                default:

        }
        return PropertySubType.NONE;
    }
}

Add default case to supress warning

Add default case to supress warning


package mb.statix.constraints.messages;

import java.util.Map;

import javax.annotation.Nullable;

import com.google.common.collect.ImmutableMap;

import mb.statix.constraints.CAstId;
import mb.statix.constraints.CAstProperty;
import mb.statix.constraints.CTry;
import mb.statix.solver.IConstraint;

public class MessageUtil {

    // @formatter:off
    private static Map<Class<? extends IConstraint>, MessageKind> KINDS =
        ImmutableMap.<Class<? extends IConstraint>, MessageKind>builder()
            .put(CAstId.class, MessageKind.WARNING)
            .put(CAstProperty.class, MessageKind.WARNING)
            .put(CTry.class, MessageKind.WARNING)
            .build();
    // @formatter:on

    public static IMessage findClosestMessage(IConstraint c) {
        return findClosestMessage(c, KINDS.getOrDefault(c.getClass(), MessageKind.ERROR));
    }

    /**
     * Find closest message in the
     */
    public static IMessage findClosestMessage(IConstraint c, MessageKind kind) {
        @Nullable IMessage message = null;
        while(c != null) {
            @Nullable IMessage m;
            if((m = c.message().orElse(null)) != null && (message == null || message.kind().isWorseThan(m.kind()))) {
                message = m;
            }
            c = c.cause().orElse(null);
        }
        if(message == null) {
            message = new Message(kind);
        }
        return message;
    }

}

package mb.statix.constraints.messages;

import java.util.Map;

import javax.annotation.Nullable;

import com.google.common.collect.ImmutableMap;

import mb.statix.constraints.CAstId;
import mb.statix.constraints.CAstProperty;
import mb.statix.constraints.CTry;
import mb.statix.solver.IConstraint;

public class MessageUtil {

    // @formatter:off
    private static Map<Class<? extends IConstraint>, MessageKind> KINDS =
        ImmutableMap.<Class<? extends IConstraint>, MessageKind>builder()
            .put(CAstId.class, MessageKind.WARNING)
            .put(CAstProperty.class, MessageKind.WARNING)
            .build();
    // @formatter:on

    public static IMessage findClosestMessage(IConstraint c) {
        return findClosestMessage(c, KINDS.getOrDefault(c.getClass(), MessageKind.ERROR));
    }

    /**
     * Find closest message in the
     */
    public static IMessage findClosestMessage(IConstraint c, MessageKind kind) {
        @Nullable IMessage message = null;
        while(c != null) {
            @Nullable IMessage m;
            if((m = c.message().orElse(null)) != null && (message == null || message.kind().isWorseThan(m.kind()))) {
                message = m;
            }
            c = c.cause().orElse(null);
        }
        if(message == null) {
            message = new Message(kind);
        }
        return message;
    }

}

Revert reduced failure level for try.

Revert reduced failure level for try.


package net.darkhax.bookshelf.api.item;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentCategory;
import net.minecraft.world.level.ItemLike;

import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;

public interface ICreativeTabBuilder<BT extends ICreativeTabBuilder<BT>> {

    default BT setIcon(ItemLike icon) {

        return this.setIcon(new ItemStack(icon));
    }

    default BT setIcon(ItemStack icon) {

        return setIcon(() -> icon);
    }

    BT setIcon(Supplier<ItemStack> iconSupplier);

    BT setEnchantmentCategories(EnchantmentCategory... categories);

    default BT setTabContents(List<ItemStack> items) {

        return setTabContents(tabContents -> tabContents.addAll(items));
    }

    BT setTabContents(Consumer<List<ItemStack>> contentSupplier);

    CreativeModeTab build();

    ResourceLocation getTabId();
}

package net.darkhax.bookshelf.api.item;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentCategory;
import net.minecraft.world.level.ItemLike;

import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;

public interface ICreativeTabBuilder<BT extends ICreativeTabBuilder<BT>> {

    default BT setIcon(ItemLike icon) {

        return this.setIcon(new ItemStack(icon));
    }

    default BT setIcon(ItemStack icon) {

        return setIcon(() -> icon);
    }

    default BT setIconItem(Supplier<ItemLike> iconSupplier) {

        return this.setIcon(() -> new ItemStack(iconSupplier.get()));
    }

    BT setIcon(Supplier<ItemStack> iconSupplier);

    BT setEnchantmentCategories(EnchantmentCategory... categories);

    default BT setTabContents(List<ItemStack> items) {

        return setTabContents(tabContents -> tabContents.addAll(items));
    }

    BT setTabContents(Consumer<List<ItemStack>> contentSupplier);

    CreativeModeTab build();

    ResourceLocation getTabId();
}

Add support for item tab icon suppliers.


package com.github.aureliano.edocs.app.helper;

import java.net.URL;

import javax.swing.Icon;
import javax.swing.ImageIcon;

public final class GuiHelper {

	private GuiHelper() {}

	public static Icon createIcon(String resource) {
		URL url = ClassLoader.getSystemResource(resource);
		return new ImageIcon(url);
	}
}

package com.github.aureliano.edocs.app.helper;

import java.awt.Component;
import java.net.URL;

import javax.swing.Icon;
import javax.swing.ImageIcon;

import com.github.aureliano.edocs.app.gui.configuration.wizard.DatabasePanel;
import com.github.aureliano.edocs.app.gui.configuration.wizard.RepositoryPanel;
import com.github.aureliano.edocs.app.gui.configuration.wizard.SecurePanel;
import com.github.aureliano.edocs.common.config.AppConfiguration;
import com.github.aureliano.edocs.common.config.DatabaseConfiguration;
import com.github.aureliano.edocs.common.config.FileRepositoryConfiguration;
import com.github.aureliano.edocs.common.config.SecureConfiguration;
import com.github.aureliano.edocs.common.exception.EDocsException;

public final class GuiHelper {

	private GuiHelper() {}

	public static Icon createIcon(String resource) {
		URL url = ClassLoader.getSystemResource(resource);
		return new ImageIcon(url);
	}

	public static AppConfiguration buildConfigurationFromWizard(Component[] components) {
		SecureConfiguration secure = new SecureConfiguration();
		DatabaseConfiguration database = new DatabaseConfiguration();
		FileRepositoryConfiguration repo = new FileRepositoryConfiguration();

		AppConfiguration configuration = new AppConfiguration()
			.withSecureConfiguration(secure)
			.withDatabaseConfiguration(database)
			.withFileRepositoryConfiguration(repo);

		for (Component c : components) {
			if (c instanceof SecurePanel) {
				SecurePanel panel = (SecurePanel) c;
				secure
					.withAlgorithm(panel.getAlgorithm().name())
					.withSalt(panel.getSalt())
					.withHashIterations(panel.getHashIterations());
			} else if (c instanceof DatabasePanel) {
				DatabasePanel panel = (DatabasePanel) c;
				database
					.withUser(panel.getUserName())
					.withPassword(panel.getPassword());
			} else if (c instanceof RepositoryPanel) {
				RepositoryPanel panel = (RepositoryPanel) c;
				repo
					.withRepositoryType(panel.getRepositoryType().name())
					.withRootPath(panel.getRepositoryFile().getAbsolutePath())
					.withLimboPath(panel.getLimboFile().getAbsolutePath());
			} else {
				throw new EDocsException("Unknown panel card type: " + c.getClass().getName());
			}
		}

		return configuration;
	}
}

Add method to build configuration model from wizard.


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

Former-commit-id: 60c52e31de5de813cbe1db16a291aadcaa473f90


/*
 * 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

svn path=/incubator/harmony/enhanced/classlib/trunk/; revision=410563


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

git-svn-id: bdb5f82b9b83a1400e05d69d262344b821646179@1387 e217846f-e12e-0410-a4e5-89ccaea66ff7


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

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

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

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

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

Fix ruler menu for breakpoints

Review URL: http://codereview.chromium.org/99357


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.

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(data): 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

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

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

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

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

git-svn-id: 3d1f0b8d955af71bf8e09c956c180519124e4717@22271 2c54a935-e501-0410-bc05-97a93f6bca70