package com.uwetrottmann.shopr.algorithm.model;

import java.math.BigDecimal;

/**
 * Represents a item (e.g. clothing item), or one case in the case-base.
 */
public class Item {

    private int id;

    private String name;

    private BigDecimal price;

    private int shop_id;

    private Attributes attrs;

    private double querySimilarity;

    private double quality;

    public int id() {
        return id;
    }

    public Item id(int id) {
        this.id = id;
        return this;
    }

    public String name() {
        return name;
    }

    public Item name(String name) {
        this.name = name;
        return this;
    }

    public BigDecimal price() {
        return price;
    }

    public Item price(BigDecimal price) {
        this.price = price;
        return this;
    }

    public int shopId() {
        return shop_id;
    }

    public Item shopId(int shop_id) {
        this.shop_id = shop_id;
        return this;
    }

    public Attributes attributes() {
        return attrs;
    }

    public Item attributes(Attributes attrs) {
        this.attrs = attrs;
        return this;
    }

    public double querySimilarity() {
        return querySimilarity;
    }

    public Item querySimilarity(double querySimilarity) {
        this.querySimilarity = querySimilarity;
        return this;
    }

    public double quality() {
        return quality;
    }

    public Item quality(double quality) {
        this.quality = quality;
        return this;
    }

}

package com.uwetrottmann.shopr.algorithm.model;

import java.math.BigDecimal;

/**
 * Represents a item (e.g. clothing item), or one case in the case-base.
 */
public class Item {

    private int id;

    private String name;

    private BigDecimal price;

    private String image_url;

    private int shop_id;

    private Attributes attrs;

    private double querySimilarity;

    private double quality;

    public int id() {
        return id;
    }

    public Item id(int id) {
        this.id = id;
        return this;
    }

    public String name() {
        return name;
    }

    public Item name(String name) {
        this.name = name;
        return this;
    }

    public BigDecimal price() {
        return price;
    }

    public Item price(BigDecimal price) {
        this.price = price;
        return this;
    }

    public String image() {
        return image_url;
    }

    public Item image(String image_url) {
        this.image_url = image_url;
        return this;
    }

    public int shopId() {
        return shop_id;
    }

    public Item shopId(int shop_id) {
        this.shop_id = shop_id;
        return this;
    }

    public Attributes attributes() {
        return attrs;
    }

    public Item attributes(Attributes attrs) {
        this.attrs = attrs;
        return this;
    }

    public double querySimilarity() {
        return querySimilarity;
    }

    public Item querySimilarity(double querySimilarity) {
        this.querySimilarity = querySimilarity;
        return this;
    }

    public double quality() {
        return quality;
    }

    public Item quality(double quality) {
        this.quality = quality;
        return this;
    }

}

Add image url to item model.

Add image url to item model.


/*
 * Copyright (c) 2020. Center for Open Science
 *
 * 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.cos.cas.authentication.exceptions;

import javax.security.auth.login.AccountException;

/**
 * Describes an error condition where authentication has failed during authentication delegation.
 *
 * @author Michael Haselton
 * @author Longze Chen
 * @since 20.1.0
 */
public class RemoteUserFailedLoginException extends AccountException {

    private static final long serialVersionUID = 3472948140572518658L;

    /** Instantiates a new exception (default). */
    public RemoteUserFailedLoginException() {
        super();
    }

    /**
     * Instantiates a new exception with a given message.
     *
     * @param message the message
     */
    public RemoteUserFailedLoginException(final String message) {
        super(message);
    }
}

/*
 * Copyright (c) 2020. Center for Open Science
 *
 * 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.cos.cas.authentication.exceptions;

import javax.security.auth.login.AccountException;

/**
 * Describes an error condition where authentication has failed during institutional authentication delegation.
 *
 * TODO: Divide this exception into two or more detailed ones. For example, one for failure in parsing required
 *       attributes from authenticated Shibboleth session (InstitutionLoginFailedException), one for failure in
 *       communicating with OSF API (OsfApiFailedException), etc.
 *
 * @author Michael Haselton
 * @author Longze Chen
 * @since 20.1.0
 */
public class RemoteUserFailedLoginException extends AccountException {

    private static final long serialVersionUID = 3472948140572518658L;

    /** Instantiates a new exception (default). */
    public RemoteUserFailedLoginException() {
        super();
    }

    /**
     * Instantiates a new exception with a given message.
     *
     * @param message the message
     */
    public RemoteUserFailedLoginException(final String message) {
        super(message);
    }
}

Add a TODO comment for splitting the "remoteUserFailedLogin" error


package com.williammora.openfeed.fragments;

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

import com.williammora.openfeed.R;
import com.williammora.openfeed.activities.StatusActivity;
import com.williammora.openfeed.adapters.viewholders.StatusViewHolder;

import twitter4j.Status;

public class StatusFragment extends Fragment {

    private static final String SAVED_STATUS = "SAVED_STATUS";

    private Status mStatus;

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

        if (savedInstanceState != null) {
            mStatus = (Status) savedInstanceState.getSerializable(SAVED_STATUS);
        } else {
            mStatus = (Status) getActivity().getIntent().getSerializableExtra(StatusActivity.EXTRA_STATUS);
        }

        StatusViewHolder viewHolder = new StatusViewHolder(view, getActivity());
        viewHolder.updateView(mStatus);

        return view;
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        outState.putSerializable(SAVED_STATUS, mStatus);
        super.onSaveInstanceState(outState);
    }
}

package com.williammora.openfeed.fragments;

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

import com.williammora.openfeed.R;
import com.williammora.openfeed.activities.StatusActivity;
import com.williammora.openfeed.adapters.viewholders.StatusViewHolder;

import twitter4j.Status;

public class StatusFragment extends Fragment {

    private static final String SAVED_STATUS = "SAVED_STATUS";

    private Status mStatus;

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

        if (savedInstanceState != null) {
            mStatus = (Status) savedInstanceState.getSerializable(SAVED_STATUS);
        } else {
            mStatus = (Status) getActivity().getIntent().getSerializableExtra(StatusActivity.EXTRA_STATUS);
        }

        StatusViewHolder viewHolder = new StatusViewHolder(view, view.getContext());
        viewHolder.updateView(mStatus);

        return view;
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        outState.putSerializable(SAVED_STATUS, mStatus);
        super.onSaveInstanceState(outState);
    }
}

Change of context for picture transformation


package com.facebook.fresco.middleware;

import android.graphics.PointF;
import android.graphics.Rect;
import android.net.Uri;
import com.facebook.fresco.ui.common.ControllerListener2.Extras;
import java.util.Map;
import javax.annotation.Nullable;

public class MiddlewareUtils {

  public static Extras obtainExtras(
      Map<String, Object> componentAttribution,
      Map<String, Object> shortcutAttribution,
      @Nullable Map<String, Object> dataSourceExtras,
      @Nullable Rect viewportDimensions,
      @Nullable String scaleType,
      @Nullable PointF focusPoint,
      @Nullable Map<String, Object> imageExtras,
      @Nullable Object callerContext,
      @Nullable Uri mainUri) {
    final Extras extras = new Extras();

    if (viewportDimensions != null) {
      extras.viewportWidth = viewportDimensions.width();
      extras.viewportHeight = viewportDimensions.height();
    }
    extras.scaleType = scaleType;
    if (focusPoint != null) {
      extras.focusX = focusPoint.x;
      extras.focusY = focusPoint.y;
    }

    extras.callerContext = callerContext;
    extras.mainUri = mainUri;

    extras.datasourceExtras = dataSourceExtras;
    extras.imageExtras = imageExtras;
    extras.shortcutExtras = shortcutAttribution;
    extras.componentExtras = componentAttribution;

    return extras;
  }
}

package com.facebook.fresco.middleware;

import android.graphics.PointF;
import android.graphics.Rect;
import android.net.Uri;
import com.facebook.fresco.ui.common.ControllerListener2.Extras;
import com.facebook.infer.annotation.Nullsafe;
import java.util.Map;
import javax.annotation.Nullable;

@Nullsafe(Nullsafe.Mode.STRICT)
public class MiddlewareUtils {

  public static Extras obtainExtras(
      Map<String, Object> componentAttribution,
      Map<String, Object> shortcutAttribution,
      @Nullable Map<String, Object> dataSourceExtras,
      @Nullable Rect viewportDimensions,
      @Nullable String scaleType,
      @Nullable PointF focusPoint,
      @Nullable Map<String, Object> imageExtras,
      @Nullable Object callerContext,
      @Nullable Uri mainUri) {
    final Extras extras = new Extras();

    if (viewportDimensions != null) {
      extras.viewportWidth = viewportDimensions.width();
      extras.viewportHeight = viewportDimensions.height();
    }
    extras.scaleType = scaleType;
    if (focusPoint != null) {
      extras.focusX = focusPoint.x;
      extras.focusY = focusPoint.y;
    }

    extras.callerContext = callerContext;
    extras.mainUri = mainUri;

    extras.datasourceExtras = dataSourceExtras;
    extras.imageExtras = imageExtras;
    extras.shortcutExtras = shortcutAttribution;
    extras.componentExtras = componentAttribution;

    return extras;
  }
}

Mark middleware class as nullsafe

Mark middleware class as nullsafe

Reviewed By: defHLT

Differential Revision: D24256184

fbshipit-source-id: cf0342d0ed800576ce0cad9a37bcd96d8483ae4a


package org.jetbrains.plugins.groovy.util;

import com.intellij.util.containers.ConcurrentHashMap;
import org.jetbrains.annotations.NotNull;

/**
 * @author Sergey Evdokimov
 */
public class ClassInstanceCache {

  private static final ConcurrentHashMap<String, Object> CACHE = new ConcurrentHashMap<String, Object>();

  private ClassInstanceCache() {
  }

  @SuppressWarnings("unchecked")
  public static <T> T getInstance(@NotNull String className) {
    Object res = CACHE.get(className);
    if (res != null) return (T)res;

    try {
      Object instance = Class.forName(className).newInstance();

      Object oldValue = CACHE.putIfAbsent(className, instance);
      if (oldValue != null) {
        instance = oldValue;
      }

      return (T)instance;
    }
    catch (Exception e) {
      throw new RuntimeException(e);
    }
  }

}

package org.jetbrains.plugins.groovy.util;

import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.util.containers.ConcurrentHashMap;
import org.jetbrains.annotations.NotNull;

/**
 * @author Sergey Evdokimov
 */
public class ClassInstanceCache {

  private static final ConcurrentHashMap<String, Object> CACHE = new ConcurrentHashMap<String, Object>();

  private ClassInstanceCache() {
  }

  private static Object createInstance(@NotNull String className) {
    try {
      try {
        return Class.forName(className).newInstance();
      }
      catch (ClassNotFoundException e) {
        for (IdeaPluginDescriptor descriptor : PluginManager.getPlugins()) {
          try {
            return descriptor.getPluginClassLoader().loadClass(className).newInstance();
          }
          catch (ClassNotFoundException ignored) {

          }
        }

        throw new RuntimeException("Class not found: " + className);
      }
    }
    catch (Exception e) {
      throw new RuntimeException(e);
    }
  }

  @SuppressWarnings("unchecked")
  public static <T> T getInstance(@NotNull String className) {
    Object res = CACHE.get(className);
    if (res == null) {
      res = createInstance(className);

      Object oldValue = CACHE.putIfAbsent(className, res);
      if (oldValue != null) {
        res = oldValue;
      }
    }

    return (T)res;
  }

}

Fix EA-30104: ClassNotFound exception: Don't forget that plugins loaded by different class loader.


package me.proxer.library.api;

import me.proxer.library.util.ProxerUrls;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;

/**
 * @author Ruben Gees
 */
final class HeaderInterceptor implements Interceptor {

    private static final String API_KEY_HEADER = "proxer-api-key";
    private static final String HEADER_USER_AGENT = "User-Agent";

    private final String apiKey;
    private final String userAgent;

    HeaderInterceptor(@NotNull final String apiKey, @Nullable final String userAgent) {
        this.apiKey = apiKey;
        this.userAgent = userAgent;
    }

    @Override
    public Response intercept(final Chain chain) throws IOException {
        final Request oldRequest = chain.request();

        if (ProxerUrls.hasProxerHost(oldRequest.url())) {
            final Request.Builder newRequestBuilder = chain.request().newBuilder().addHeader(API_KEY_HEADER, apiKey);

            if (userAgent != null) {
                newRequestBuilder.addHeader(HEADER_USER_AGENT, userAgent);
            }

            return chain.proceed(newRequestBuilder.build());
        } else {
            return chain.proceed(oldRequest);
        }
    }
}

package me.proxer.library.api;

import me.proxer.library.util.ProxerUrls;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;

/**
 * @author Ruben Gees
 */
final class HeaderInterceptor implements Interceptor {

    private static final String API_KEY_HEADER = "proxer-api-key";
    private static final String HEADER_USER_AGENT = "User-Agent";

    private final String apiKey;
    private final String userAgent;

    HeaderInterceptor(@NotNull final String apiKey, @Nullable final String userAgent) {
        this.apiKey = apiKey;
        this.userAgent = userAgent;
    }

    @Override
    public Response intercept(final Chain chain) throws IOException {
        final Request oldRequest = chain.request();

        if (ProxerUrls.hasProxerHost(oldRequest.url())) {
            final Request.Builder newRequestBuilder = chain.request().newBuilder().addHeader(API_KEY_HEADER, apiKey);

            if (userAgent != null) {
                newRequestBuilder.removeHeader(HEADER_USER_AGENT);
                newRequestBuilder.addHeader(HEADER_USER_AGENT, userAgent);
            }

            return chain.proceed(newRequestBuilder.build());
        } else {
            return chain.proceed(oldRequest);
        }
    }
}

Remove any previous set User-Agents when set


package sizebay.catalog.client.model;

import java.io.Serializable;
import java.util.Map;
import lombok.*;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
@NoArgsConstructor
public class ProductBasicInformation implements Serializable {

	long id;
	@NonNull String name;
	@NonNull String permalink;
	String genderTheWearWasDesignedFor;
	String coverImage;
	int isShoe;
	@Deprecated int szbMainCategoryId; // FIXME Remove this field after legacy virtual dead
	@Deprecated int szbSubCategoryId; // FIXME Remove this field after legacy virtual dead
	@Deprecated String szbMainCategoryName = null; // FIXME Remove this field after legacy virtual dead
	@Deprecated String szbSubCategoryName = null; // FIXME Remove this field after legacy virtual dead
	String categoryName;
	String modelingName;
	@Deprecated boolean bottomOnly;
	ClothesType clothesType;
	String sizeType;
	Boolean status;
	Product.AgeGroupEnum ageGroup = null;
	Map<String, ModelingSizeMeasures> measures;
	Boolean accessory;
	int strongBrandId;
	String strongBrandName;
	int strongCategoryTypeId;
	String strongCategoryTypeName;
	int strongCategoryId;
	String strongCategoryName;
	int strongSubcategoryId;
	String strongSubcategoryName;
	int strongModelId;
	String strongModelName;
	double weightSize;
}

package sizebay.catalog.client.model;

import java.io.Serializable;
import java.util.Map;
import lombok.*;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
@NoArgsConstructor
public class ProductBasicInformation implements Serializable {

	long id;
	@NonNull String name;
	@NonNull String permalink;
	String genderTheWearWasDesignedFor;
	String coverImage;
	int isShoe;
	@Deprecated int szbMainCategoryId; // FIXME Remove this field after legacy virtual dead
	@Deprecated int szbSubCategoryId; // FIXME Remove this field after legacy virtual dead
	@Deprecated String szbMainCategoryName = null; // FIXME Remove this field after legacy virtual dead
	@Deprecated String szbSubCategoryName = null; // FIXME Remove this field after legacy virtual dead
	String categoryName;
	String modelingName;
	@Deprecated boolean bottomOnly;
	ClothesType clothesType;
	String sizeType;
	Boolean status;
	Product.AgeGroupEnum ageGroup = null;
	Map<String, ModelingSizeMeasures> measures;
	Boolean accessory;
	int strongBrandId;
	String strongBrandName;
	int strongCategoryTypeId;
	String strongCategoryTypeName;
	int strongCategoryId;
	String strongCategoryName;
	int strongSubcategoryId;
	String strongSubcategoryName;
	int strongModelId;
	String strongModelName;
	double weightStyle;
}

Ref: Change attribute name weightSize to weightStyle


package nickrout.lenslauncher.util;

import android.graphics.Color;
import android.support.annotation.ColorInt;
import android.support.v7.graphics.Palette;

import nickrout.lenslauncher.model.App;

/**
 * Created by nicholasrout on 2016/05/28.
 */
public class ColorUtil {

    public static @ColorInt int getPaletteColorFromApp(App app) {
        Palette palette = Palette.from(app.getIcon()).generate();
        if (palette.getSwatches().size() > 0) {
            int swatchIndex = 0;
            for (int i = 1; i < palette.getSwatches().size(); i++) {
                if (palette.getSwatches().get(i).getPopulation()
                        > palette.getSwatches().get(swatchIndex).getPopulation()) {
                    swatchIndex = i;
                }
            }
            return palette.getSwatches().get(swatchIndex).getRgb();
        } else {
            return Color.BLACK;
        }
    }

    public static float getHueColorFromApp(App app) {
        float[] hsvValues = new float[3];
        Color.colorToHSV(app.getPaletteColor(), hsvValues);
        return hsvValues[0];
    }
}

package nickrout.lenslauncher.util;

import android.graphics.Color;
import android.support.annotation.ColorInt;
import android.support.v7.graphics.Palette;

import nickrout.lenslauncher.model.App;

/**
 * Created by nicholasrout on 2016/05/28.
 */
public class ColorUtil {

    public static @ColorInt int getPaletteColorFromApp(App app) {
        Palette palette;
        try {
            palette = Palette.from(app.getIcon()).generate();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            return Color.BLACK;
        }
        if (palette.getSwatches().size() > 0) {
            int swatchIndex = 0;
            for (int i = 1; i < palette.getSwatches().size(); i++) {
                if (palette.getSwatches().get(i).getPopulation()
                        > palette.getSwatches().get(swatchIndex).getPopulation()) {
                    swatchIndex = i;
                }
            }
            return palette.getSwatches().get(swatchIndex).getRgb();
        } else {
            return Color.BLACK;
        }
    }

    public static float getHueColorFromApp(App app) {
        float[] hsvValues = new float[3];
        Color.colorToHSV(app.getPaletteColor(), hsvValues);
        return hsvValues[0];
    }
}

Fix for occasional Palette crash

Fix for occasional Palette crash


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

package com.splunk;

/**
 * Representation of Message.
 */
public class Message extends Entity {

    /**
     * Class Constructor.
     *
     * @param service The connected service instance.
     * @param path The message endpoint.
     */
    Message(Service service, String path) {
        super(service, path);
    }

    /**
     * Returns this message's title.
     * @return This message's title.
     */
    public String getKey() {
        return getTitle();
    }

    /**
     * Returns this message's value.
     * @return This message's value.
     */
    public String getValue() {
        return getString(getKey());
    }
}

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

package com.splunk;

/**
 * Representation of Message.
 */
public class Message extends Entity {

    /**
     * Class Constructor.
     *
     * @param service The connected service instance.
     * @param path The message endpoint.
     */
    Message(Service service, String path) {
        super(service, path);
    }

    /**
     * Returns this message's title.
     *
     * @return This message's title.
     */
    public String getKey() {
        return getTitle();
    }

    /**
     * Returns this message's value.
     *
     * @return This message's value.
     */
    public String getValue() {
        return getString(getKey());
    }
}

Add whitespace to be consistent with other modules


package au.gov.ga.geodesy.igssitelog.domain.model;

import org.springframework.data.jpa.repository.JpaRepository;
import au.gov.ga.geodesy.domain.model.Event;

public interface EventRepository extends JpaRepository<Event, Integer> {
}

package au.gov.ga.geodesy.igssitelog.domain.model;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import au.gov.ga.geodesy.domain.model.Event;

public interface EventRepository extends JpaRepository<Event, Integer> {

    @Query("select e from Event e where e.timeHandled is null")
    List<Event> getPendingEvents();
}

Add method to fetch pending events.

Add method to fetch pending events.


package me.nallar.tickthreading.minecraft.commands;

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

import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;

public abstract class Command extends CommandBase {
	public static void sendChat(ICommandSender commandSender, String message) {
		while (message != null) {
			int nlIndex = message.indexOf('\n');
			String sent;
			if (nlIndex == -1) {
				sent = message;
				message = null;
			} else {
				sent = message.substring(0, nlIndex);
				message = message.substring(nlIndex + 1);
			}
			commandSender.sendChatToPlayer(sent);
		}
	}

	@Override
	public final void processCommand(ICommandSender commandSender, String... argumentsArray) {
		processCommand(commandSender, new ArrayList<String>(Arrays.asList(argumentsArray)));
	}

	protected abstract void processCommand(ICommandSender commandSender, List<String> arguments);
}

package me.nallar.tickthreading.minecraft.commands;

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

import me.nallar.tickthreading.Log;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;

public abstract class Command extends CommandBase {
	public static void sendChat(ICommandSender commandSender, String message) {
		if (commandSender == MinecraftServer.getServer()) {
			Log.info('\n' + message);
			return;
		}
		while (message != null) {
			int nlIndex = message.indexOf('\n');
			String sent;
			if (nlIndex == -1) {
				sent = message;
				message = null;
			} else {
				sent = message.substring(0, nlIndex);
				message = message.substring(nlIndex + 1);
			}
			commandSender.sendChatToPlayer(sent);
		}
	}

	@Override
	public final void processCommand(ICommandSender commandSender, String... argumentsArray) {
		processCommand(commandSender, new ArrayList<String>(Arrays.asList(argumentsArray)));
	}

	protected abstract void processCommand(ICommandSender commandSender, List<String> arguments);
}

Include console command output in logs.

Include console command output in logs.

Signed-off-by: Ross Allan <ca2c77e14df1e7ee673215c1ef658354e220f471@gmail.com>


package org.junit.internal.matchers;

import static org.hamcrest.CoreMatchers.any;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.internal.matchers.StacktracePrintingMatcher.isException;
import static org.junit.internal.matchers.StacktracePrintingMatcher.isThrowable;
import org.junit.Test;

public class StacktracePrintingMatcherTest {

	@Test
	public void succeedsWhenInnerMatcherSuceeds() throws Exception {
		assertTrue(isThrowable(any(Throwable.class)).matches(new Exception()));
	}

	@Test
	public void failsWhenInnerMatcherFails() throws Exception {
		assertFalse(isException(notNullValue(Exception.class)).matches(null));
	}

	@Test
	public void assertThatIncludesStacktrace() {
		Exception actual= new IllegalArgumentException("my message");
		Exception expected= new NullPointerException();

		try {
			assertThat(actual, isThrowable(equalTo(expected)));
		} catch (AssertionError e) {
			assertThat(e.getMessage(), containsString("Stacktrace was: java.lang.IllegalArgumentException: my message"));
		}
	}
}

package org.junit.internal.matchers;

import static org.hamcrest.CoreMatchers.any;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.internal.matchers.StacktracePrintingMatcher.isException;
import static org.junit.internal.matchers.StacktracePrintingMatcher.isThrowable;
import org.junit.Test;

public class StacktracePrintingMatcherTest {

	@Test
	public void succeedsWhenInnerMatcherSucceeds() throws Exception {
		assertTrue(isThrowable(any(Throwable.class)).matches(new Exception()));
	}

	@Test
	public void failsWhenInnerMatcherFails() throws Exception {
		assertFalse(isException(notNullValue(Exception.class)).matches(null));
	}

	@Test
	public void assertThatIncludesStacktrace() {
		Exception actual= new IllegalArgumentException("my message");
		Exception expected= new NullPointerException();

		try {
			assertThat(actual, isThrowable(equalTo(expected)));
		} catch (AssertionError e) {
			assertThat(e.getMessage(), containsString("Stacktrace was: java.lang.IllegalArgumentException: my message"));
		}
	}
}

Fix typo in test name

Fix typo in test name


/*
 * Created by Koen Deschacht (koendeschacht@gmail.com) 2017-4-28. For license
 * information see the LICENSE file in the root folder of this repository.
 */

package be.bagofwords.minidepi.remote;

import be.bagofwords.exec.RemoteExecConfig;
import be.bagofwords.util.SocketConnection;

import java.io.IOException;

public class RemoteExecService {

    public static final String SOCKET_NAME = "remote-exec";

    public SocketConnection execRemotely(String host, int port, RemoteExecConfig remoteExecConfig) throws IOException {
        SocketConnection socketConnection = new SocketConnection(host, port, SOCKET_NAME);
        socketConnection.writeValue(remoteExecConfig.pack());
        return socketConnection;
    }

}

/*
 * Created by Koen Deschacht (koendeschacht@gmail.com) 2017-4-28. For license
 * information see the LICENSE file in the root folder of this repository.
 */

package be.bagofwords.minidepi.remote;

import be.bagofwords.exec.RemoteExecConfig;
import be.bagofwords.util.SocketConnection;
import org.apache.commons.io.IOUtils;

import java.io.IOException;

public class RemoteExecService {

    public static final String SOCKET_NAME = "remote-exec";

    public SocketConnection execRemotely(String host, int port, RemoteExecConfig remoteExecConfig) throws IOException {
        SocketConnection socketConnection = new SocketConnection(host, port, SOCKET_NAME);
        socketConnection.writeValue(remoteExecConfig.pack());
        boolean success = socketConnection.readBoolean();
        if (!success) {
            String error = socketConnection.readString();
            socketConnection.writeBoolean(true);
            IOUtils.closeQuietly(socketConnection);
            String remoteError = "\nREMOTE ERROR START:\n" + error + "\nREMOTE ERROR END\n";
            throw new RuntimeException("Failed to execute remote class " + remoteExecConfig.getExecutorClassName() + remoteError);
        } else {
            socketConnection.writeBoolean(true);
        }
        return socketConnection;
    }

}

Return error messages if the compilation of remote methods fails


package net.afterlifelochie.fontbox.layout;

public class ObjectBounds {

	public int x, y;
	public int width, height;
	public boolean floating;

	public ObjectBounds(int x, int y, int width, int height, boolean floating) {
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
		this.floating = floating;
	}

	public boolean floating() {
		return floating;
	}

}

package net.afterlifelochie.fontbox.layout;

public class ObjectBounds {

	public int x, y;
	public int width, height;
	public boolean floating;

	public ObjectBounds(int x, int y, int width, int height, boolean floating) {
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
		this.floating = floating;
	}

	public boolean floating() {
		return floating;
	}

	public boolean intersects(ObjectBounds that) {
		boolean flag0 = (this.x < that.x + that.width && this.x + this.width > that.x);
		boolean flag1 = (this.y < that.y + that.height && this.y + this.height > that.y);
		return flag0 && flag1;
	}
}

Add intersects to objectbounds prototype


package org.kohsuke.github;

/**
 * Hook event type.
 *
 * See http://developer.github.com/v3/events/types/
 *
 * @author Kohsuke Kawaguchi
 * @see GHEventInfo
 */
public enum GHEvent {
    COMMIT_COMMENT,
    CREATE,
    DELETE,
    DOWNLOAD,
    FOLLOW,
    FORK,
    FORK_APPLY,
    GIST,
    GOLLUM,
    ISSUE_COMMENT,
    ISSUES,
    MEMBER,
    PUBLIC,
    PULL_REQUEST,
    PULL_REQUEST_REVIEW_COMMENT,
    PUSH,
    TEAM_ADD,
    WATCH
}

package org.kohsuke.github;

/**
 * Hook event type.
 *
 * See http://developer.github.com/v3/events/types/
 *
 * @author Kohsuke Kawaguchi
 * @see GHEventInfo
 */
public enum GHEvent {
    COMMIT_COMMENT,
    CREATE,
    DELETE,
    DEPLOYMENT,
    DEPLOYMENT_STATUS,
    DOWNLOAD,
    FOLLOW,
    FORK,
    FORK_APPLY,
    GIST,
    GOLLUM,
    ISSUE_COMMENT,
    ISSUES,
    MEMBER,
    PUBLIC,
    PULL_REQUEST,
    PULL_REQUEST_REVIEW_COMMENT,
    PUSH,
    RELEASE,
    STATUS,
    TEAM_ADD,
    WATCH
}

Add missing DEPLOYMENT, DEPLOYMENT_STATUS, RELEASE and STATUS events.


package com.box.boxjavalibv2.authorization;

/**
 * Interface for UI to generate auth.
 */
public interface IAuthFlowUI {

    /**
     * Authenticate.
     *
     * @param listener
     *            listener listening to events/messages fired during authentication process.
     */
    void authenticate(IAuthFlowListener listener);

    /**
     * Initialize the UI for OAuth flow. This needs to be called everytime before starting an auth flow.
     */
    void initializeAuthFlow(final Object applicationContext, String clientId, String clientSecret);

    /**
     * Initialize the UI for OAuth flow. This needs to be called everytime before starting an auth flow.
     */
    void initializeAuthFlow(final Object applicationContext, String clientId, String clientSecret, String redirectUrl);

}

package com.box.boxjavalibv2.authorization;

import com.box.boxjavalibv2.BoxClient;

/**
 * Interface for UI to generate auth.
 */
public interface IAuthFlowUI {

    /**
     * Authenticate.
     *
     * @param listener
     *            listener listening to events/messages fired during authentication process.
     */
    void authenticate(IAuthFlowListener listener);

    /**
     * Initialize the UI for OAuth flow. This needs to be called everytime before starting an auth flow.
     */
    void initializeAuthFlow(final Object applicationContext, String clientId, String clientSecret);

    /**
     * Initialize the UI for OAuth flow. This needs to be called everytime before starting an auth flow.
     */
    void initializeAuthFlow(final Object applicationContext, String clientId, String clientSecret, String redirectUrl);

    void initializeAuthFlow(Object activity, String clientId, String clientSecret, String redirectUrl, BoxClient boxClient);

}

Allow passing in box client when intializing OauthWebView


package org.kobjects.nativehtml.android;

import android.content.Context;
import android.widget.FrameLayout;
import java.io.Reader;
import java.net.URI;
import org.kobjects.nativehtml.dom.Element;
import org.kobjects.nativehtml.io.DefaultRequestHandler;
import org.kobjects.nativehtml.io.HtmlParser;
import org.kobjects.nativehtml.io.InternalLinkHandler;

public class HtmlView extends FrameLayout implements InternalLinkHandler {
    private final AndroidPlatform platform;
    private final HtmlParser htmlParser;
    private DefaultRequestHandler requestHandler;

    public HtmlView(Context context) {
        super(context);
        platform = new AndroidPlatform(context);
        requestHandler = new DefaultRequestHandler(platform);
        requestHandler.setInternalLinkHandler(this);
        htmlParser = new HtmlParser(platform, requestHandler, null);
    }

    public void addInternalLinkPrefix(String s) {
        requestHandler.addInternalLinkPrefix(s);
    }

    public void loadHtml(URI url) {
        requestHandler.openInternalLink(url);
    }

    public void loadHtml(Reader reader, URI baseUrl) {
        Element element = htmlParser.parse(reader, baseUrl);

        removeAllViews();
        if (element instanceof AbstractAndroidComponentElement) {
            addView((AbstractAndroidComponentElement) element);
        }
    }

}

package org.kobjects.nativehtml.android;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;

import org.kobjects.nativehtml.dom.Element;
import org.kobjects.nativehtml.io.DefaultRequestHandler;
import org.kobjects.nativehtml.io.HtmlParser;
import org.kobjects.nativehtml.io.InternalLinkHandler;

import java.io.Reader;
import java.net.URI;

public class HtmlView extends FrameLayout implements InternalLinkHandler {
    private HtmlParser htmlParser;
    private DefaultRequestHandler requestHandler;

    public HtmlView(Context context) {
        super(context);
        init(context);
    }

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

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

    private void init(Context context) {
        AndroidPlatform platform = new AndroidPlatform(context);
        requestHandler = new DefaultRequestHandler(platform);
        requestHandler.setInternalLinkHandler(this);
        htmlParser = new HtmlParser(platform, requestHandler, null);
    }

    public void addInternalLinkPrefix(String s) {
        requestHandler.addInternalLinkPrefix(s);
    }

    public void loadHtml(URI url) {
        requestHandler.openInternalLink(url);
    }

    public void loadHtml(Reader reader, URI baseUrl) {
        Element element = htmlParser.parse(reader, baseUrl);

        removeAllViews();
        if (element instanceof AbstractAndroidComponentElement) {
            addView((AbstractAndroidComponentElement) element);
        }
    }

}

Add the required constructors for direct usage in layout xml files.

Usage: <org.kobjects.nativehtml.android.HtmlView>


package etomica.meta;

import org.reflections.Reflections;

import java.util.Set;

public class ComponentIndex<T> {
    private final Class<T> componentClass;

    private static final Reflections reflections = new Reflections("etomica");

    public ComponentIndex(Class<T> componentClass) {
        this.componentClass = componentClass;
    }

    public Set<Class<? extends T>> getComponentSet() {
        return reflections.getSubTypesOf(componentClass);
    }
}

package etomica.meta;

import org.reflections.Reflections;

import java.util.Set;

import static etomica.meta.Common.REFLECTIONS;

public class ComponentIndex<T> {
    private final Class<T> componentClass;

    public ComponentIndex(Class<T> componentClass) {
        this.componentClass = componentClass;
    }

    public Set<Class<? extends T>> getComponentSet() {
        return REFLECTIONS.getSubTypesOf(componentClass);
    }
}

Use common reflections instance to avoid scanning twice


/**
 * Copyright 2013 Asakusa Framework Team.
 *
 * 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.asakusafw.shafu.internal.asakusafw.preferences;

/**
 * Preference constants of Shafu Asakusa Plug-in.
 */
public final class ShafuAsakusaPreferenceConstants {

    /**
     * The preference key of catalog URL.
     */
    public static final String KEY_CATALOG_URL = "catalog"; //$NON-NLS-1$

    /**
     * The default value of catalog URL.
     */
    public static final String DEFAULT_CATALOG_URL =
            "http://www.asakusafw.com/download/gradle-plugin/template-catalog.txt"; //$NON-NLS-1$

    private ShafuAsakusaPreferenceConstants() {
        return;
    }
}

/**
 * Copyright 2013 Asakusa Framework Team.
 *
 * 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.asakusafw.shafu.internal.asakusafw.preferences;

/**
 * Preference constants of Shafu Asakusa Plug-in.
 */
public final class ShafuAsakusaPreferenceConstants {

    /**
     * The URL (prefix) of download site.
     */
    private static final String URL_DOWNLOAD_SITE = "http://www.asakusafw.com/download/gradle-plugin/"; //$NON-NLS-1$

    /**
     * The preference key of catalog URL.
     */
    public static final String KEY_CATALOG_URL = "catalog"; //$NON-NLS-1$

    /**
     * The default value of catalog URL.
     */
    public static final String DEFAULT_CATALOG_URL = URL_DOWNLOAD_SITE + "template-catalog-release.txt"; //$NON-NLS-1$

    private ShafuAsakusaPreferenceConstants() {
        return;
    }
}

Change asakusafw project template catalog URL.


package ${packageName};

import static org.junit.Assert.*;

public class ${testClassName} {

    private final ${productionClassName} production = new ${productionClassName}("value");

    @org.junit.Test
    public void testOne() throws Exception {
        for (int i = 0; i < 500; i++) {
            System.out.println("Some test output from ${testClassName}.testOne - " + i);
            System.err.println("Some test error  from ${testClassName}.testOne - " + i);
            if (i % 50 == 0) {
                Thread.sleep(1);
            }
        }
        assertEquals(production.getProperty(), "value");
    }

    @org.junit.Test
    public void testTwo() throws Exception {
        for (int i = 0; i < 500; i++) {
            System.out.println("Some test output from ${testClassName}.testTwo - " + i);
            System.err.println("Some test error  from ${testClassName}.testTwo - " + i);
            if (i % 50 == 0) {
                Thread.sleep(1);
            }
        }
        String expected = <%= binding.hasVariable("halfTestsFail") && binding.halfTestsFail ? "\"foo\"" : "\"value\"" %>;
        assertEquals(production.getProperty(), expected);
    }
}

package ${packageName};

import static org.junit.Assert.*;

public class ${testClassName} {

    private final ${productionClassName} production = new ${productionClassName}("value");

    @org.junit.Test
    public void testOne() throws Exception {
        for (int i = 0; i < 500; i++) {
            System.out.println("Some test output from ${testClassName}.testOne - " + i);
            System.err.println("Some test error  from ${testClassName}.testOne - " + i);
            if (i % 20 == 0) {
                Thread.sleep(1);
            }
        }
        assertEquals(production.getProperty(), "value");
    }

    @org.junit.Test
    public void testTwo() throws Exception {
        for (int i = 0; i < 500; i++) {
            System.out.println("Some test output from ${testClassName}.testTwo - " + i);
            System.err.println("Some test error  from ${testClassName}.testTwo - " + i);
            if (i % 20 == 0) {
                Thread.sleep(1);
            }
        }
        String expected = <%= binding.hasVariable("halfTestsFail") && binding.halfTestsFail ? "\"foo\"" : "\"value\"" %>;
        assertEquals(production.getProperty(), expected);
    }
}

Make tests more realistic by doing some “work” other than writing console output, moreso.


//Foobar
package ch.uzh.ifi.dachs.pizza;

public class Pizza {

	public static void main(String[] args) {
		// Parameter inpute filename
		System.out.println("Dachs Pizza");
	}

}

//Foobar
package ch.uzh.ifi.dachs.pizza;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Pizza {

	static {
		StackTraceElement[] stack = Thread.currentThread().getStackTrace();
		StackTraceElement main = stack[stack.length - 1];
		PROGRAM_NAME = main.getClassName();
	}

	public static String PROGRAM_NAME;

	public static void main(String[] args) throws FileNotFoundException {
		// Parameter inpute filename
		if(args.length != 1) {
			System.out.println("Usage: " + Pizza.PROGRAM_NAME + " input_filename");
			return;
		}

		String filename = args[0];
		Scanner scanner = new Scanner(new File(filename));

		int rows = scanner.nextInt();
		int columns = scanner.nextInt();
		int ingredients = scanner.nextInt();
		int max_cells = scanner.nextInt();

		Pizza solution = new Pizza(rows, columns, ingredients, max_cells);

		String line;
		int i = 0;
		while(scanner.hasNextLine()) {
			line = scanner.nextLine();
			if(line.isEmpty()) {
				continue;
			}
			for(int j = 0; j < columns; j++) {
				solution.setCell(i, j, line.charAt(j));
			}
			i++;
		}

		scanner.close();

		System.out.println(solution.asciiMatrix());
	}

	private int rows;
	private int columns;
	private int ingredients;
	private int max_cells;

	private static final boolean T = true;
	private static final boolean M = false;

	private boolean pizza[][];

	public Pizza(int rows, int columns, int ingredients, int max_cells) {
		this.rows = rows;
		this.columns = columns;
		this.ingredients = ingredients;
		this.max_cells = max_cells;

		this.pizza = new boolean[rows][columns];
	}

	private boolean parseCellValue(char cell) {
		return cell == 'T';
	}

	private String asciiCellValue(boolean cell) {
		return cell ? "T" : "M";
	}

	public void setCell(int row, int column, char cell) {
		this.pizza[row][column] = this.parseCellValue(cell);
	}

	public String asciiMatrix() {
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < this.rows; i++) {
			for(int j = 0; j < this.columns; j++) {
				sb.append(this.asciiCellValue(this.pizza[i][j]));
			}
			sb.append("\n");
		}
		return sb.toString();
	}
}

Read input and print matrix (pizza) state


package com.azure.tools.apiview.processor.diagnostics.rules;

import com.azure.tools.apiview.processor.diagnostics.DiagnosticRule;
import com.azure.tools.apiview.processor.model.APIListing;
import com.azure.tools.apiview.processor.model.Diagnostic;
import com.github.javaparser.ast.CompilationUnit;

import java.util.regex.Pattern;

import static com.azure.tools.apiview.processor.analysers.util.ASTUtils.*;

public class PackageNameDiagnosticRule implements DiagnosticRule {
    final static Pattern regex = Pattern.compile("^com.azure.[a-z0-9]*(\\.[a-z0-9]+)+[0-9a-z]$");

    @Override
    public void scan(final CompilationUnit cu, final APIListing listing) {
        getPackageName(cu).ifPresent(packageName -> {
            // we need to map the issue to the class id, because package text isn't printed in the APIView output
            getClassName(cu).map(listing.getKnownTypes()::get).ifPresent(typeId -> {
                if (!regex.matcher(packageName).matches()) {
                    listing.addDiagnostic(new Diagnostic(typeId,
                            "Package name must start with 'com.azure', and it must be lower-case, with no underscores or hyphens."));
                }
            });
        });
    }
}

package com.azure.tools.apiview.processor.diagnostics.rules;

import com.azure.tools.apiview.processor.diagnostics.DiagnosticRule;
import com.azure.tools.apiview.processor.model.APIListing;
import com.azure.tools.apiview.processor.model.Diagnostic;
import com.github.javaparser.ast.CompilationUnit;

import java.util.regex.Pattern;

import static com.azure.tools.apiview.processor.analysers.util.ASTUtils.*;

public class PackageNameDiagnosticRule implements DiagnosticRule {
    final static Pattern regex = Pattern.compile("^com.azure(\\.[a-z0-9]+)+$");

    @Override
    public void scan(final CompilationUnit cu, final APIListing listing) {
        getPackageName(cu).ifPresent(packageName -> {
            // we need to map the issue to the class id, because package text isn't printed in the APIView output
            getClassName(cu).map(listing.getKnownTypes()::get).ifPresent(typeId -> {
                if (!regex.matcher(packageName).matches()) {
                    listing.addDiagnostic(new Diagnostic(typeId,
                            "Package name must start with 'com.azure', and it must be lower-case, with no underscores or hyphens."));
                }
            });
        });
    }
}

Fix regex for package naming diagnostic

Fix regex for package naming diagnostic


package ee.tuleva.onboarding.account;

import ee.tuleva.onboarding.auth.principal.Person;
import ee.tuleva.onboarding.epis.EpisService;
import ee.tuleva.onboarding.epis.account.FundBalanceDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

import static java.util.stream.Collectors.toList;

@Service
@Slf4j
@RequiredArgsConstructor
public class AccountStatementService {

  private final EpisService episService;
  private final FundBalanceDtoToFundBalanceConverter fundBalanceConverter;

  public List<FundBalance> getAccountStatement(Person person) {
    List<FundBalanceDto> accountStatement = episService.getAccountStatement(person);

    return accountStatement.stream()
        .map(fundBalanceDto -> convertToFundBalance(fundBalanceDto, person))
        .collect(toList());
  }

  private FundBalance convertToFundBalance(FundBalanceDto fundBalanceDto, Person person) {
    try {
      return fundBalanceConverter.convert(fundBalanceDto);
    } catch(IllegalArgumentException e) {
      throw new IllegalStateException("Could not convert fund balance for person " + person, e);
    }
  }
}

package ee.tuleva.onboarding.account;

import ee.tuleva.onboarding.auth.principal.Person;
import ee.tuleva.onboarding.epis.EpisService;
import ee.tuleva.onboarding.epis.account.FundBalanceDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

import static java.util.stream.Collectors.toList;

@Service
@Slf4j
@RequiredArgsConstructor
public class AccountStatementService {

  private final EpisService episService;
  private final FundBalanceDtoToFundBalanceConverter fundBalanceConverter;

  public List<FundBalance> getAccountStatement(Person person) {
    List<FundBalanceDto> accountStatement = episService.getAccountStatement(person);

    return accountStatement.stream()
        .map(fundBalanceDto -> convertToFundBalance(fundBalanceDto, person))
        .collect(toList());
  }

  private FundBalance convertToFundBalance(FundBalanceDto fundBalanceDto, Person person) {
    try {
        if (log.isDebugEnabled()) {
            log.debug("Fund Balance DTO:" + fundBalanceDto);
        }
      return fundBalanceConverter.convert(fundBalanceDto);
    } catch(IllegalArgumentException e) {
      throw new IllegalStateException("Could not convert fund balance for person " + person, e);
    }
  }
}

Allow log-in for people who don+t have pension account Enable DTO debug


// (c) 2012 B Smith-Mannschott -- Distributed under the Eclipse Public License
package bpsm.edn.model;

import bpsm.edn.parser.util.Interner;

public final class Keyword implements Named, Comparable<Keyword> {
    private final Symbol sym;

    public final String getPrefix() {
        return sym.getPrefix();
    }

    public final String getName() {
        return sym.getName();
    }

    public static Keyword newKeyword(Symbol sym) {
        return INTERNER.intern(sym, new Keyword(sym));
    }

    private Keyword(Symbol sym) {
        if (sym == null) {
            throw new NullPointerException();
        }
        this.sym = sym;
    }

    public String toString() {
        return ":" + sym.toString();
    }

    public int compareTo(Keyword o) {
        return sym.compareTo(o.sym);
    }

    private static final Interner<Symbol, Keyword> INTERNER =
            new Interner<Symbol, Keyword>();

}

// (c) 2012 B Smith-Mannschott -- Distributed under the Eclipse Public License
package bpsm.edn.model;

import bpsm.edn.parser.util.Interner;

public final class Keyword implements Named, Comparable<Keyword> {
    private final Symbol sym;

    public final String getPrefix() {
        return sym.getPrefix();
    }

    public final String getName() {
        return sym.getName();
    }

    public static Keyword newKeyword(Symbol sym) {
        return INTERNER.intern(sym, new Keyword(sym));
    }

    private Keyword(Symbol sym) {
        if (sym == null) {
            throw new NullPointerException();
        }
        this.sym = sym;
    }

    public String toString() {
        return ":" + sym.toString();
    }

    public int compareTo(Keyword o) {
    	if (this==o) return 0;
        return sym.compareTo(o.sym);
    }

    private static final Interner<Symbol, Keyword> INTERNER =
            new Interner<Symbol, Keyword>();

}

Add fast path for comparing to an identical (interned) keyword


/*
 * Copyright (C) 2014 Red Hat, Inc.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 *
 *  Authors : Dave Tucker
 */

package org.opendaylight.neutron.northbound.api;

import org.opendaylight.neutron.spi.INeutronObject;

import java.util.List;

public interface INeutronRequest<T extends INeutronObject> {
    public T getSingleton();
    public boolean isSingleton();
    public List<T> getBulk();
}

/*
 * Copyright (C) 2014 Red Hat, Inc.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 *
 *  Authors : Dave Tucker
 */

package org.opendaylight.neutron.northbound.api;

import org.opendaylight.neutron.spi.INeutronObject;

import java.util.List;

public interface INeutronRequest<T extends INeutronObject> {
    T getSingleton();
    boolean isSingleton();
    List<T> getBulk();
}

Remove redundant modifiers from northbound interfaces

Change-Id: I83ed14c21255e8fc22bd688d00ea8b87d833b344
Signed-off-by: Ryan Moats <7ac70bcc48c94124ee1b01a4779bf5a8a6faebbd@us.ibm.com>


package org.ovirt.engine.core.utils;

import org.ovirt.engine.core.common.utils.EnumUtils;

import junit.framework.TestCase;

public class EnumUtilsTest extends TestCase {
    public void testConvertToStringWithSpaces() {
        assertEquals("Hello There", EnumUtils.ConvertToStringWithSpaces("HelloThere"));
    }
}

package org.ovirt.engine.core.utils;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.ovirt.engine.core.common.utils.EnumUtils;

public class EnumUtilsTest {

    @Test
    public void convertToStringWithSpaces() {
        assertEquals("Hello There", EnumUtils.ConvertToStringWithSpaces("HelloThere"));
    }
}

Change to JUnit 4 test

backend: Change to JUnit 4 test

Change the test to be junit 4 test for adding more tests later.

Change-Id: I7a8d38bbbbce976f5bf12573bb6936e5d7ff7c1e


package io.quarkus.smallrye.reactivemessaging.runtime;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

import javax.enterprise.context.Dependent;
import javax.enterprise.event.Observes;
import javax.inject.Inject;

import io.quarkus.runtime.StartupEvent;
import io.smallrye.reactive.messaging.extension.MediatorManager;

@Dependent
public class SmallRyeReactiveMessagingLifecycle {

    @Inject
    MediatorManager mediatorManager;

    void onApplicationStart(@Observes StartupEvent event) {
        CompletableFuture<Void> future = mediatorManager.initializeAndRun();
        try {
            future.get();
        } catch (ExecutionException e) {
            throw new RuntimeException(e.getCause());
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

}

package io.quarkus.smallrye.reactivemessaging.runtime;

import javax.enterprise.context.Dependent;
import javax.enterprise.event.Observes;
import javax.inject.Inject;

import io.quarkus.runtime.StartupEvent;
import io.smallrye.reactive.messaging.extension.MediatorManager;

@Dependent
public class SmallRyeReactiveMessagingLifecycle {

    @Inject
    MediatorManager mediatorManager;

    void onApplicationStart(@Observes StartupEvent event) {
        try {
            mediatorManager.initializeAndRun();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

Update how is started the Reactive Messaging provider


package ca.intelliware.ihtsdo.mlds.registration;

import java.util.List;

import javax.annotation.Resource;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

@Transactional
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:applicationContext.xml", "classpath:applicationContext-integrationTest.xml"})
public class UserRegistrationIntegrationTest {
	@Resource
	UserRegistrationController controller;

	@Resource
	UserRegistrationRepository userRegistrationRepository;

	@Test
	public void createRegistrationViaAPIAndFindIt() throws Exception {
		String email = "email" + System.currentTimeMillis() + "@example.com";
		controller.createRegistration(email);

		List<UserRegistration> found = userRegistrationRepository.findByEmail(email);
		Assert.assertTrue("found some", !found.isEmpty());

	}
}

package ca.intelliware.ihtsdo.mlds.registration;

import java.util.List;

import javax.annotation.Resource;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

@Transactional
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={
		"classpath:applicationContext.xml",
		"classpath:applicationContext-integrationTest.xml",
		"file:src/main/webapp/WEB-INF/dispatcher-servlet.xml"})
public class UserRegistrationIntegrationTest {
	@Resource
	UserRegistrationController controller;

	@Resource
	UserRegistrationRepository userRegistrationRepository;

	@Test
	public void createRegistrationViaAPIAndFindIt() throws Exception {
		String email = "email" + System.currentTimeMillis() + "@example.com";
		controller.createRegistration(email);

		List<UserRegistration> found = userRegistrationRepository.findByEmail(email);
		Assert.assertTrue("found some", !found.isEmpty());

	}
}

Fix up test definition to account for pushing @Controller definitions out to servlet context


package org.atlasapi.application.auth;

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

import javax.servlet.http.HttpServletRequest;

import org.atlasapi.application.Application;
import org.atlasapi.application.ApplicationSources;
import org.atlasapi.application.ApplicationStore;

import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;

public class ApiKeySourcesFetcher implements ApplicationSourcesFetcher {

    public static final String API_KEY_QUERY_PARAMETER = "key";

    private final ApplicationStore reader;

    public ApiKeySourcesFetcher(ApplicationStore reader) {
        this.reader = checkNotNull(reader);
    }

    @Override
    public ImmutableSet<String> getParameterNames() {
        return ImmutableSet.of(API_KEY_QUERY_PARAMETER);
    }

    @Override
    public Optional<ApplicationSources> sourcesFor(HttpServletRequest request) throws InvalidApiKeyException  {
        String apiKey = request.getParameter(API_KEY_QUERY_PARAMETER);
        if (apiKey == null) {
            apiKey = request.getHeader(API_KEY_QUERY_PARAMETER);
        }
        if (apiKey != null) {
            Optional<Application> app = reader.applicationForKey(apiKey);
            if (!app.isPresent() || app.get().isRevoked()) {
                throw new InvalidApiKeyException(apiKey);
            }
            return Optional.of(app.get().getSources());
        }
        return Optional.absent();
    }
}

package org.atlasapi.application.auth;

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

import javax.servlet.http.HttpServletRequest;

import org.atlasapi.application.Application;
import org.atlasapi.application.ApplicationSources;
import org.atlasapi.application.ApplicationStore;

import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;

public class ApiKeySourcesFetcher implements ApplicationSourcesFetcher {

    public static final String API_KEY_QUERY_PARAMETER = "key";

    private final ApplicationStore reader;

    public ApiKeySourcesFetcher(ApplicationStore reader) {
        this.reader = checkNotNull(reader);
    }

    @Override
    public ImmutableSet<String> getParameterNames() {
        return ImmutableSet.of();
    }

    @Override
    public Optional<ApplicationSources> sourcesFor(HttpServletRequest request) throws InvalidApiKeyException  {
        String apiKey = request.getParameter(API_KEY_QUERY_PARAMETER);
        if (apiKey == null) {
            apiKey = request.getHeader(API_KEY_QUERY_PARAMETER);
        }
        if (apiKey != null) {
            Optional<Application> app = reader.applicationForKey(apiKey);
            if (!app.isPresent() || app.get().isRevoked()) {
                throw new InvalidApiKeyException(apiKey);
            }
            return Optional.of(app.get().getSources());
        }
        return Optional.absent();
    }
}

Revert "Revert "api key deleted from the list of required parameters""


/*
 * Copyright 2015 Real Logic Ltd.
 *
 * 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 uk.co.real_logic.benchmarks.latency;

public class Configuration
{
    public static final int MAX_THREAD_COUNT = 4;
    public static final int SEND_QUEUE_CAPACITY = 64 * 1024;
    public static final int RESPONSE_QUEUE_CAPACITY = 4 * 1024;
}

/*
 * Copyright 2015 Real Logic Ltd.
 *
 * 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 uk.co.real_logic.benchmarks.latency;

public class Configuration
{
    public static final int MAX_THREAD_COUNT = 4;
    public static final int SEND_QUEUE_CAPACITY = 64 * 1024;
    public static final int RESPONSE_QUEUE_CAPACITY = 32 * 1024;
}

Increase size of response queue.

Increase size of response queue.


package de.timroes.axmlrpc.serializer;

import java.text.SimpleDateFormat;

import org.w3c.dom.Element;

import de.timroes.axmlrpc.XMLRPCException;
import de.timroes.axmlrpc.XMLUtil;
import de.timroes.axmlrpc.xmlcreator.XmlElement;
import fr.turri.jiso8601.Iso8601Deserializer;

/**
 *
 * @author timroes
 */
public class DateTimeSerializer implements Serializer {

	private static final String DATETIME_FORMAT = "yyyyMMdd'T'HHmmss";
	private final SimpleDateFormat DATE_FORMATER = new SimpleDateFormat(DATETIME_FORMAT);

	@Override
	public Object deserialize(Element content) throws XMLRPCException {
		return deserialize(XMLUtil.getOnlyTextContent(content.getChildNodes()));
	}

	public Object deserialize(String dateStr) throws XMLRPCException {
		try {
			return Iso8601Deserializer.toDate(dateStr);
		} catch (Exception ex) {
			throw new XMLRPCException("Unable to parse given date.", ex);
		}
	}

	@Override
	public XmlElement serialize(Object object) {
		return XMLUtil.makeXmlTag(SerializerHandler.TYPE_DATETIME,
				DATE_FORMATER.format(object));
	}

}

package de.timroes.axmlrpc.serializer;

import java.text.SimpleDateFormat;

import org.w3c.dom.Element;

import de.timroes.axmlrpc.XMLRPCException;
import de.timroes.axmlrpc.XMLUtil;
import de.timroes.axmlrpc.xmlcreator.XmlElement;
import fr.turri.jiso8601.Iso8601Deserializer;

/**
 *
 * @author timroes
 */
public class DateTimeSerializer implements Serializer {

	private static final String DATETIME_FORMAT = "yyyyMMdd'T'HHmmss";
	private final SimpleDateFormat DATE_FORMATER = new SimpleDateFormat(DATETIME_FORMAT);

	@Override
	public Object deserialize(Element content) throws XMLRPCException {
		return deserialize(XMLUtil.getOnlyTextContent(content.getChildNodes()));
	}

	public Object deserialize(String dateStr) throws XMLRPCException {
		if (dateStr==null || dateStr.trim().length()==0)
			return null;
		try {
			return Iso8601Deserializer.toDate(dateStr);
		} catch (Exception ex) {
			throw new XMLRPCException("Unable to parse given date.", ex);
		}
	}

	@Override
	public XmlElement serialize(Object object) {
		return XMLUtil.makeXmlTag(SerializerHandler.TYPE_DATETIME,
				DATE_FORMATER.format(object));
	}

}

Return empty datetime elements as NULL

Return empty datetime elements as NULL


package org.ligoj.app.plugin.prov.model;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import lombok.Getter;
import lombok.Setter;

/**
 * Storage price for a storage type.

 * The meaning to the cost attribute is the monthly cost of 1GiB (1024 MiB).
 */
@Getter
@Setter
@Entity
@Table(name = "LIGOJ_PROV_STORAGE_PRICE", uniqueConstraints = @UniqueConstraint(columnNames = { "type", "location" }))
public class ProvStoragePrice extends AbstractPrice<ProvStorageType> {

	/**
	 * The monthly cost of 1GiB (Gibibyte Bytes).
	 * @see https://en.wikipedia.org/wiki/Gibibyte
	 */
	private double costGb = 0;

	/**
	 * The cost per transaction. May be 0.
	 */
	private double costTransaction;
}

package org.ligoj.app.plugin.prov.model;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import lombok.Getter;
import lombok.Setter;

/**
 * Storage price for a storage type.

 * The meaning to the cost attribute is the monthly cost of 1GiB (1024 MiB).
 */
@Getter
@Setter
@Entity
@Table(name = "LIGOJ_PROV_STORAGE_PRICE", uniqueConstraints = @UniqueConstraint(columnNames = { "type", "location" }))
public class ProvStoragePrice extends AbstractPrice<ProvStorageType> {

	/**
	 * The monthly cost of 1GiB (Gibibyte Bytes).
	 * @see https://en.wikipedia.org/wiki/Gibibyte
	 */
	private double costGb = 0;

	/**
	 * The cost per million transactions. May be 0.
	 */
	private double costTransaction;
}

Use 1M transaction cost model instead of 10,000


package org.sagebionetworks.web.client.cookie;

/**
 * The cookie key master.  Don't tell the cookie monster!
 *
 * @author jmhill
 *
 */
public class CookieKeys {

	/**
	 * Key for the selected columns shown in the datasets table.
	 */
	public static String SELECTED_DATASETS_COLUMNS = "org.sagebionetworks.datasets.selected.columns";

	/**
	 * Key for the selected filters applied on the datasets table.
	 */
	public static String APPLIED_DATASETS_FILTERS = "org.sagebionetworks.datasets.applied.filters";

	/**
	 * Login token
	 */
	public static String USER_LOGIN_TOKEN = "org.sagbionetworks.security.user.login.token";

	/**
	 * Login token
	 */
	public static String SHOW_DEMO = "org.sagbionetworks.synapse.show.demo";

	/**
	 * Last Place in the app
	 */
	public static String LAST_PLACE = "org.sagbionetworks.synapse.place.last.place";

	/**
	 * Current Place in the app
	 */
	public static String CURRENT_PLACE = "org.sagbionetworks.synapse.place.current.place";

	/**
	 * LinkedIn requestToken key
	 */
	public static String LINKEDIN = "org.sagebionetworks.synapse.linkedin";

	/**
	 * Get Satisfaction fastpass key
	 */
	public static String FASTPASS = "fastpass";
}

package org.sagebionetworks.web.client.cookie;

/**
 * The cookie key master.  Don't tell the cookie monster!
 *
 * @author jmhill
 *
 */
public class CookieKeys {

	/**
	 * Key for the selected columns shown in the datasets table.
	 */
	public static String SELECTED_DATASETS_COLUMNS = "org.sagebionetworks.datasets.selected.columns";

	/**
	 * Key for the selected filters applied on the datasets table.
	 */
	public static String APPLIED_DATASETS_FILTERS = "org.sagebionetworks.datasets.applied.filters";

	/**
	 * Login token
	 */
	public static String USER_LOGIN_TOKEN = "org.sagebionetworks.security.user.login.token";

	/**
	 * Login token
	 */
	public static String SHOW_DEMO = "org.sagebionetworks.synapse.show.demo";

	/**
	 * Last Place in the app
	 */
	public static String LAST_PLACE = "org.sagebionetworks.synapse.place.last.place";

	/**
	 * Current Place in the app
	 */
	public static String CURRENT_PLACE = "org.sagebionetworks.synapse.place.current.place";

	/**
	 * LinkedIn requestToken key
	 */
	public static String LINKEDIN = "org.sagebionetworks.synapse.linkedin";

	/**
	 * Get Satisfaction fastpass key
	 */
	public static String FASTPASS = "fastpass";
}

Fix cookie keys to be 'sagebio' not 'sagbio'


package org.orienteer.core.behavior;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxClientInfoBehavior;
import org.orienteer.core.OrienteerWebSession;

/**
 * Behavior to gather ClientInfo only once
 */
public class OneTimeAjaxClientInfoBehavior extends AjaxClientInfoBehavior {

	@Override
	public boolean isEnabled(Component component) {
		return !OrienteerWebSession.get().isClientInfoAvailable();
	}

	@Override
	public boolean isTemporary(Component component) {
		return !isEnabled(component);
	}
}

package org.orienteer.core.behavior;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxClientInfoBehavior;
import org.orienteer.core.OrienteerWebSession;

/**
 * Behavior to gather ClientInfo only once
 */
public class OneTimeAjaxClientInfoBehavior extends AjaxClientInfoBehavior {

	@Override
	public boolean isEnabled(Component component) {
		return !OrienteerWebSession.get().isClientInfoAvailable();
	}
}

Fix InvalidBehaviorIdException due to dynamic swith to temporal behavior


package com.github.aureliano.achmed.server.service;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.Map;

import com.github.aureliano.achmed.common.exception.AchmedException;
import com.github.aureliano.achmed.common.helper.FileHelper;
import com.github.aureliano.achmed.common.helper.StringHelper;
import com.github.aureliano.achmed.server.AchmedServerHandler;

public class ReadFileService implements IService {

	public ReadFileService() {}

	@Override
	public byte[] consume(Map<String, String> parameters) {
		String resourcePath = parameters.get("resource");
		if (StringHelper.isEmpty(resourcePath)) {
			throw new AchmedException("Empty resource path.");
		}

		File requestedFile = FileHelper.buildFile(AchmedServerHandler.instance().getFileRepository(), resourcePath);
		if (!(requestedFile.exists() && requestedFile.isFile())) {
			try {
				return (" >>> Resource path: " + resourcePath).getBytes("UTF-8");
			} catch (UnsupportedEncodingException ex) {
				throw new AchmedException(ex);
			}
		}

		return new byte[0];
	}
}

package com.github.aureliano.achmed.server.service;

import java.io.File;
import java.util.Map;
import java.util.logging.Logger;

import com.github.aureliano.achmed.common.exception.AchmedException;
import com.github.aureliano.achmed.common.helper.FileHelper;
import com.github.aureliano.achmed.common.helper.StringHelper;
import com.github.aureliano.achmed.common.logging.LoggingFactory;
import com.github.aureliano.achmed.server.AchmedServerHandler;

public class ReadFileService implements IService {

	private static final Logger logger = LoggingFactory.createLogger(ReadFileService.class);

	public ReadFileService() {}

	@Override
	public byte[] consume(Map<String, String> parameters) {
		String resourcePath = parameters.get("resource");
		if (StringHelper.isEmpty(resourcePath)) {
			throw new AchmedException("Empty resource path.");
		}

		File requestedFile = FileHelper.buildFile(AchmedServerHandler.instance().getFileRepository(), resourcePath);
		if (!(requestedFile.exists() && requestedFile.isFile())) {
			logger.warning("Requested resource path [ " + requestedFile + " ] does not exist.");
			return new byte[0];
		}

		return new byte[0];
	}
}

Return empty array if requested file does not exist.


/*
 * #%L
 * BroadleafCommerce Framework
 * %%
 * Copyright (C) 2009 - 2014 Broadleaf Commerce
 * %%
 * 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.
 * #L%
 */
package org.broadleafcommerce.openadmin.server.service.persistence.module.provider.extension;

import org.broadleafcommerce.common.extension.ExtensionHandler;
import org.broadleafcommerce.common.extension.ExtensionResultHolder;
import org.broadleafcommerce.common.extension.ExtensionResultStatusType;
import org.broadleafcommerce.common.media.domain.Media;

/**
 * For internal usage. Allows extending API calls without subclassing the entity.
 *
 * @author Jeff Fischer
 */
public interface MediaFieldPersistenceProviderExtensionHandler extends ExtensionHandler {

    ExtensionResultStatusType transformId(Media media, ExtensionResultHolder<Long> resultHolder);

    ExtensionResultStatusType postAdd(Media media);

    ExtensionResultStatusType postUpdate(Media media);

    public static final int DEFAULT_PRIORITY = Integer.MAX_VALUE;

}

/*
 * #%L
 * BroadleafCommerce Framework
 * %%
 * Copyright (C) 2009 - 2014 Broadleaf Commerce
 * %%
 * 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.
 * #L%
 */
package org.broadleafcommerce.openadmin.server.service.persistence.module.provider.extension;

import org.broadleafcommerce.common.extension.ExtensionHandler;
import org.broadleafcommerce.common.extension.ExtensionResultHolder;
import org.broadleafcommerce.common.extension.ExtensionResultStatusType;
import org.broadleafcommerce.common.media.domain.Media;

/**
 * For internal usage. Allows extending API calls without subclassing the entity.
 *
 * @author Jeff Fischer
 */
public interface MediaFieldPersistenceProviderExtensionHandler extends ExtensionHandler {

    ExtensionResultStatusType transformId(Media media, ExtensionResultHolder<Long> resultHolder);

    ExtensionResultStatusType postAdd(Media media);

    ExtensionResultStatusType postUpdate(Media media);

    ExtensionResultStatusType checkDirtyState(Media oldMedia, Media newMedia, ExtensionResultHolder<Boolean> resultHolder);

    public static final int DEFAULT_PRIORITY = Integer.MAX_VALUE;

}

Make sure dirty state is detected appropriately during a promote


enum BeamType {

    FAR(1.0f, 0.1f, 3.0f, 0.5f, 5.0f),
    MIDDLE(2.0f, 0.2f, 6.0f, 0.7f, 7.0f),
    NEAR(3.0f, 0.3f, 9.0f, 0.9f, 9.0f);

    final float velocity;
    final float acceleration;
    final float terminalVelocity;
    final float opacity;
    final float size;

    BeamType(float velocity, float acceleration, float terminalVelocity, float opacity, float size) {
        this.velocity = velocity;
        this.acceleration = acceleration;
        this.terminalVelocity = terminalVelocity;
        this.opacity = opacity * 255;
        this.size = size;
    }

    float velocity() {
        return velocity;
    }

    float acceleration() {
        return acceleration;
    }

    float terminalVelocity() {
        return terminalVelocity;
    }

    float opacity() {
        return opacity;
    }

    float size() {
        return size;
    }
}

Nit: Fix statement exceeding 100-character line limit


/**
 * Copyright 2015 Palantir Technologies
 *
 * Licensed under the BSD-3 License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://opensource.org/licenses/BSD-3-Clause
 *
 * 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.palantir.nexus.db.sql;

import java.util.List;

public interface AgnosticResultSet {

    List<AgnosticResultRow> rows();

    AgnosticResultRow get(int row);

    int size();

}

/**
 * Copyright 2015 Palantir Technologies
 *
 * Licensed under the BSD-3 License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://opensource.org/licenses/BSD-3-Clause
 *
 * 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.palantir.nexus.db.sql;

import java.util.List;

public interface AgnosticResultSet {

    List<? extends AgnosticResultRow> rows();

    AgnosticResultRow get(int row);

    int size();

}

Support extends of the interface

Support extends of the interface


package io.katharsis.example.jersey;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.katharsis.locator.SampleJsonServiceLocator;
import io.katharsis.queryParams.DefaultQueryParamsParser;
import io.katharsis.queryParams.QueryParamsBuilder;
import io.katharsis.rs.KatharsisFeature;
import io.katharsis.rs.KatharsisProperties;
import org.glassfish.jersey.server.ResourceConfig;

import javax.ws.rs.ApplicationPath;

@ApplicationPath("/")
public class JerseyApplication extends ResourceConfig {

    public static final String APPLICATION_URL = "http://localhost:8080/";

    public JerseyApplication() {
        property(KatharsisProperties.RESOURCE_SEARCH_PACKAGE, "io.katharsis.example.jersey.domain");
        property(KatharsisProperties.RESOURCE_DEFAULT_DOMAIN, APPLICATION_URL);
        register(new KatharsisFeature(new ObjectMapper(), new QueryParamsBuilder(new DefaultQueryParamsParser()), new SampleJsonServiceLocator()));

    }
}

package io.katharsis.example.jersey;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.katharsis.locator.SampleJsonServiceLocator;
import io.katharsis.queryParams.DefaultQueryParamsParser;
import io.katharsis.queryParams.QueryParamsBuilder;
import io.katharsis.rs.KatharsisFeature;
import io.katharsis.rs.KatharsisProperties;
import org.glassfish.jersey.server.ResourceConfig;

import javax.ws.rs.ApplicationPath;

@ApplicationPath("/")
public class JerseyApplication extends ResourceConfig {

    public static final String APPLICATION_URL = "http://localhost:8080";

    public JerseyApplication() {
        property(KatharsisProperties.RESOURCE_SEARCH_PACKAGE, "io.katharsis.example.jersey.domain");
        property(KatharsisProperties.RESOURCE_DEFAULT_DOMAIN, APPLICATION_URL);
        register(new KatharsisFeature(new ObjectMapper(), new QueryParamsBuilder(new DefaultQueryParamsParser()), new SampleJsonServiceLocator()));

    }
}

Fix: Remove slash at the end of APPLICATION_URL

This corrects an issue when trying to navigate links.


/*
 * SecurityConfig.java
 *
 * Copyright (C) 2017 [ A Legge Up ]
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

package com.aleggeup.confagrid.config;

import java.security.SecureRandom;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.aleggeup.confagrid.filter.JwtFilter;

@Configuration
public class SecurityConfig {

    @Bean
    public FilterRegistrationBean jwtFilter() {
        final FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new JwtFilter());
        registrationBean.addUrlPatterns("/api/*");

        return registrationBean;
    }

    @Bean
    public SecureRandom secureRandom() {
        return new SecureRandom();
    }
}

/*
 * SecurityConfig.java
 *
 * Copyright (C) 2017 [ A Legge Up ]
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

package com.aleggeup.confagrid.config;

import java.security.SecureRandom;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.aleggeup.confagrid.filter.JwtFilter;

@Configuration
public class SecurityConfig {

    @Bean
    public FilterRegistrationBean jwtFilter() {
        final FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new JwtFilter());

        return registrationBean;
    }

    @Bean
    public SecureRandom secureRandom() {
        return new SecureRandom();
    }
}

Remove url pattern from filter so that it will filter all paths


package li.cil.oc.example.architecture;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

/**
 * This mod demonstrates how to create tile entities that are treated as
 * components by OpenComputers, i.e. tile entities that provide methods which
 * can be called from a program running on a computer.
 * <p/>
 * The mod tries to keep everything else to a minimum, to focus on the mod-
 * specific parts. It is not intended for use or distribution, but you're free
 * to base a proper addon on this code.
 */
@Mod(modid = "OpenComputers|ExampleTileEntity",
        name = "OpenComputers Addon Example - TileEntity",
        version = "1.0.0",
        dependencies = "required-after:OpenComputers@[1.2.0,)")
public class ModExampleTileEntity {
    @Mod.Instance
    public static ModExampleTileEntity instance;

    @Mod.EventHandler
    public void preInit(FMLPreInitializationEvent e) {
    	li.cil.oc.api.Machine.add(PseudoArchitecture.class);
    }
}

package li.cil.oc.example.architecture;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

/**
 * This mod demonstrates how to create tile entities that are treated as
 * components by OpenComputers, i.e. tile entities that provide methods which
 * can be called from a program running on a computer.
 * <p/>
 * The mod tries to keep everything else to a minimum, to focus on the mod-
 * specific parts. It is not intended for use or distribution, but you're free
 * to base a proper addon on this code.
 */
@Mod(modid = "OpenComputers|ExampleArchitecture",
        name = "OpenComputers Addon Example - Architecture",
        version = "1.0.0",
        dependencies = "required-after:OpenComputers@[1.4.0,)")
public class ModExampleArchitecture {
    @Mod.Instance
    public static ModExampleArchitecture instance;

    @Mod.EventHandler
    public void preInit(FMLPreInitializationEvent e) {
    	li.cil.oc.api.Machine.add(PseudoArchitecture.class);
    }
}

Change Mod Class and name

Change Mod Class and name


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

public final class JMXSupport {

    private JMXSupport() {
    }

    public static String encodeObjectNamePart(String part) {
        // return ObjectName.quote(part);
        String answer = part.replaceAll("[\\:\\,\\'\\\"]", "_");
        answer = answer.replaceAll("\\?", "&qe;");
        answer = answer.replaceAll("=", "&");
        answer = answer.replaceAll("\\*", "*");
        return answer;
    }
}

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

import java.util.regex.Pattern;

public final class JMXSupport {

    private static final Pattern PART_1 = Pattern.compile("[\\:\\,\\'\\\"]");
    private static final Pattern PART_2 = Pattern.compile("\\?");
    private static final Pattern PART_3 = Pattern.compile("=");
    private static final Pattern PART_4 = Pattern.compile("\\*");

    private JMXSupport() {
    }

    public static String encodeObjectNamePart(String part) {
        String answer = PART_1.matcher(part).replaceAll("_");
        answer = PART_2.matcher(answer).replaceAll("&qe;");
        answer = PART_3.matcher(answer).replaceAll("&");
        answer = PART_4.matcher(answer).replaceAll("*");
        return answer;
    }

}

AMQ-4010: Use pre compiled pattern when doing string replaceAll as its faster.

git-svn-id: d2a93f579bd4835921162e9a69396c846e49961c@1379761 13f79535-47bb-0310-9956-ffa450edef68


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

package org.killbill.billing.plugin.notification.templates;

import java.util.Map;

import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;

public class MustacheTemplateEngine implements TemplateEngine {

    @Override
    public String executeTemplateText(final String templateText, final Map<String, Object> data) {
        final Template template = Mustache.compiler().compile(templateText);
        return template.execute(data);
    }
}

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

package org.killbill.billing.plugin.notification.templates;

import java.util.Map;

import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;

public class MustacheTemplateEngine implements TemplateEngine {

    @Override
    public String executeTemplateText(final String templateText, final Map<String, Object> data) {
        final Template template = Mustache.compiler().nullValue("").compile(templateText);
        return template.execute(data);
    }
}

Fix Mustache compiler to default null values to empty strings, not throw exception.


package com.airbnb.lotte.layers;

import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;

import com.airbnb.lotte.utils.LotteTransform3D;
import com.airbnb.lotte.utils.Observable;

public class RootLotteAnimatableLayer extends LotteAnimatableLayer {
    public RootLotteAnimatableLayer(Drawable.Callback callback) {
        super(0, callback);
    }

    @Override
    public void draw(@NonNull Canvas canvas) {
        setTransform(new Observable<>(new LotteTransform3D()));
        super.draw(canvas);
        canvas.clipRect(getBounds());
    }
}

package com.airbnb.lotte.layers;

import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;

public class RootLotteAnimatableLayer extends LotteAnimatableLayer {
    public RootLotteAnimatableLayer(Drawable.Callback callback) {
        super(0, callback);
    }

    @Override
    public void draw(@NonNull Canvas canvas) {
        super.draw(canvas);
        canvas.clipRect(getBounds());
    }
}

Remove transform from root layer

Remove transform from root layer


/*
 * VowlThing.java
 *
 */

package de.uni_stuttgart.vis.vowl.owl2vowl.model.entities.nodes.classes;

import de.uni_stuttgart.vis.vowl.owl2vowl.constants.NodeType;
import de.uni_stuttgart.vis.vowl.owl2vowl.constants.Standard_Iris;

import de.uni_stuttgart.vis.vowl.owl2vowl.model.annotation.Annotation;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.visitor.VowlElementVisitor;
import org.semanticweb.owlapi.model.IRI;

/**
 *
 */
public class VowlThing extends AbstractClass {
	public static final String THING_IRI = Standard_Iris.OWL_THING_CLASS_URI;

	protected VowlThing(IRI iri, String type) {
		super(iri, type);
	}

	public VowlThing(IRI iri) {
		super(iri, NodeType.TYPE_THING);
		getAnnotations().addLabel(new Annotation("label", "Thing"));
	}

	@Override
	public void accept(VowlElementVisitor visitor) {
		visitor.visit(this);
	}
}

/*
 * VowlThing.java
 *
 */

package de.uni_stuttgart.vis.vowl.owl2vowl.model.entities.nodes.classes;

import de.uni_stuttgart.vis.vowl.owl2vowl.constants.NodeType;
import de.uni_stuttgart.vis.vowl.owl2vowl.constants.Standard_Iris;

import de.uni_stuttgart.vis.vowl.owl2vowl.model.annotation.Annotation;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.visitor.VowlElementVisitor;
import org.semanticweb.owlapi.model.IRI;

/**
 *
 */
public class VowlThing extends AbstractClass {
	public static final String THING_IRI = Standard_Iris.OWL_THING_CLASS_URI;
	public static final IRI GENERIC_THING_IRI = IRI.create(THING_IRI);

	protected VowlThing(IRI iri, String type) {
		super(iri, type);
	}

	public VowlThing(IRI iri) {
		super(iri, NodeType.TYPE_THING);
		getAnnotations().addLabel(new Annotation("label", "Thing"));
	}

	@Override
	public void accept(VowlElementVisitor visitor) {
		visitor.visit(this);
	}
}

Fix bug with missing iri

Fix bug with missing iri


package com.nilhcem.mowitnow;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.apache.commons.io.FileUtils;

/**
 * Starting point of the application.
 *
 * <p>
 * Opens file passed in args and calls the Mower interpreter.
 * </p>
 */
public final class App {

	public static void main(String[] args) throws IOException {
		List<String> instructions = App.getInstructionsFromArgFile(args);
	}

	private static List<String> getInstructionsFromArgFile(String[] args) throws IOException {
		if (args.length != 1) {
			throw new IllegalArgumentException("App is expecting one (and only one) parameter: the mower instructions file");
		}

		File instructions = new File(args[0]);
		return FileUtils.readLines(instructions, "UTF-8");
	}
}

package com.nilhcem.mowitnow;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.apache.commons.io.FileUtils;

import com.nilhcem.mowitnow.core.Mower;
import com.nilhcem.mowitnow.core.instruction.MowerInstruction;
import com.nilhcem.mowitnow.core.instruction.parser.InstructionsParser;

/**
 * Starting point of the application.
 * <p>
 * Opens file passed in args and calls the Mower interpreter.
 * </p>
 */
public final class App {

	private App() {
	}

	public static void main(String[] args) throws IOException {
		List<String> instructions = App.getInstructionsFromArgFile(args);
		runInstructions(instructions);
	}

	private static List<String> getInstructionsFromArgFile(String[] args) throws IOException {
		if (args.length != 1) {
			throw new IllegalArgumentException("App is expecting one (and only one) parameter: the mower instructions file");
		}

		File instructions = new File(args[0]);
		return FileUtils.readLines(instructions, "UTF-8");
	}

	private static void runInstructions(List<String> data) {
		InstructionsParser parser = new InstructionsParser(data);

		Mower mower = parser.getNextMower();
		while (mower != null) {
			List<MowerInstruction> instrs = parser.getInstructionsForMower(mower);
			for (MowerInstruction instr : instrs) {
				mower.process(instr);
			}
			System.out.println(mower.getPosition());
			mower = parser.getNextMower();
		}
	}
}

Add main code (while calls core methods and displays result)


package org.helioviewer.plugins.eveplugin.view;

import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import org.helioviewer.plugins.eveplugin.view.linedataselector.LineDateSelectorTablePanel;

public class TimelinePluginPanel extends JPanel {

    private static final long serialVersionUID = -2175620741820580148L;
    private JTabbedPane tabs;

    public TimelinePluginPanel() {
        super();
        initVisualComponents();
    }

    private void initVisualComponents() {
        tabs = new JTabbedPane();
        tabs.addTab("Layers", new ControlsPanel());
        tabs.addTab("Radio Options", new RadioOptionsPanel());

        setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
        add(tabs);
        add(new LineDateSelectorTablePanel());
    }
}

package org.helioviewer.plugins.eveplugin.view;

import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import org.helioviewer.plugins.eveplugin.view.linedataselector.LineDateSelectorTablePanel;

public class TimelinePluginPanel extends JPanel {

    private static final long serialVersionUID = -2175620741820580148L;
    private JTabbedPane tabs;

    public TimelinePluginPanel() {
        super();
        initVisualComponents();
    }

    private void initVisualComponents() {
        setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
        add(new LineDateSelectorTablePanel());
    }
}

Remove the old line selector panel

Remove the old line selector panel

git-svn-id: 4e353c0944fe8da334633afc35765ef362dec675@4267 b4e469a2-07ce-4b26-9273-4d7d95a670c7