package protocolsupport.protocol.transformer.middlepacket.clientbound.play;

import java.io.IOException;

import net.minecraft.server.v1_9_R1.BlockPosition;
import protocolsupport.protocol.PacketDataSerializer;
import protocolsupport.protocol.transformer.middlepacket.ClientBoundMiddlePacket;

public abstract class MiddleSpawnPainting<T> extends ClientBoundMiddlePacket<T> {

	protected int entityId;
	protected String type;
	protected BlockPosition position;
	protected int direction;

	@Override
	public void readFromServerData(PacketDataSerializer serializer) throws IOException {
		entityId = serializer.readVarInt();
		type = serializer.readString(13);
		position = serializer.readPosition();
		direction = serializer.readByte();
	}

}

package protocolsupport.protocol.transformer.middlepacket.clientbound.play;

import java.io.IOException;
import java.util.UUID;

import net.minecraft.server.v1_9_R1.BlockPosition;
import protocolsupport.protocol.PacketDataSerializer;
import protocolsupport.protocol.transformer.middlepacket.ClientBoundMiddlePacket;

public abstract class MiddleSpawnPainting<T> extends ClientBoundMiddlePacket<T> {

	protected int entityId;
	protected UUID uuid;
	protected String type;
	protected BlockPosition position;
	protected int direction;

	@Override
	public void readFromServerData(PacketDataSerializer serializer) throws IOException {
		entityId = serializer.readVarInt();
		uuid = serializer.readUUID();
		type = serializer.readString(13);
		position = serializer.readPosition();
		direction = serializer.readUnsignedByte();
	}

}

Fix spawn painting packet reading

Fix spawn painting packet reading


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

import java.text.FieldPosition;
import java.text.Format;
import java.text.ParsePosition;

/**
 * Lightweight porting of ICU MessageFormat.
 *
 * @author hoatle (hoatlevan at gmail dot com)
 * @since Mar 23, 2012
 */
public final class MessageFormat extends Format {

  @Override
  public final StringBuffer format(final Object obj, final StringBuffer toAppendTo,
                                   final FieldPosition pos) {
    return null;  //To change body of implemented methods use File | Settings | File Templates.
  }

  @Override
  public final Object parseObject(final String source, final ParsePosition pos) {
    return null;  //To change body of implemented methods use File | Settings | File Templates.
  }
}

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

import java.text.FieldPosition;
import java.text.Format;
import java.text.ParsePosition;

/**
 * Lightweight porting of ICU MessageFormat.
 *
 * @author hoatle (hoatlevan at gmail dot com)
 * @since Mar 23, 2012
 */
public final class MessageFormat extends Format {

  @Override
  public StringBuffer format(final Object obj, final StringBuffer toAppendTo,
                                   final FieldPosition pos) {
    return null;  //To change body of implemented methods use File | Settings | File Templates.
  }

  @Override
  public Object parseObject(final String source, final ParsePosition pos) {
    return null;  //To change body of implemented methods use File | Settings | File Templates.
  }
}

Fix violations checking: * Redundant 'final' modifier


package org.alien4cloud.tosca.utils;

import org.alien4cloud.tosca.model.definitions.ImplementationArtifact;
import org.alien4cloud.tosca.model.definitions.Interface;
import org.alien4cloud.tosca.model.definitions.Operation;

import java.util.Map;
import java.util.Optional;

import static alien4cloud.utils.AlienUtils.safe;

public final class InterfaceUtils {
    private InterfaceUtils() {
    }

    public static ImplementationArtifact getArtifact(Map<String, Interface> interfaceMap, String interfaceName, String operationName) {
        Optional.of(safe(interfaceMap).get(interfaceName)).map()
        Interface interfaz = safe(interfaceMap).get(interfaceName);
        if (interfaz == null) {
            return null;
        }
        Operation operation = safe(interfaz.getOperations()).get(operationName);
        if(operation )
    }

}

package org.alien4cloud.tosca.utils;

import static alien4cloud.utils.AlienUtils.safe;

import java.util.Map;
import java.util.Optional;

import org.alien4cloud.tosca.model.definitions.ImplementationArtifact;
import org.alien4cloud.tosca.model.definitions.Interface;
import org.alien4cloud.tosca.model.definitions.Operation;

public final class InterfaceUtils {
    private InterfaceUtils() {
    }

    public static ImplementationArtifact getArtifact(Map<String, Interface> interfaceMap, String interfaceName, String operationName) {
        Optional.of(safe(interfaceMap).get(interfaceName)).map()
        Interface interfaz = safe(interfaceMap).get(interfaceName);
        if (interfaz == null) {
            return null;
        }
        Operation operation = safe(interfaz.getOperations()).get(operationName);
        if(operation == null) {
            return null;
        }
        return operation.getImplementationArtifact();
    }
}

[ALIEN-2755] Allow specific handling of docker image artifact update in the editor, util fix.


package com.bbn.bue.common;

import com.google.common.annotations.Beta;

import org.immutables.value.Value;

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

/**
 * This is the text group's default style for immutable objects generated using
 * the "Immutables.org" library. Use this whenever you use {@link org.immutables.value.Value.Immutable}
 * unless you have a strong reason to do otherwise.
 */
@Beta
@Target({ElementType.PACKAGE, ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
@Value.Style(
    // use the stripped abstract type name as the immutable type name
    // rather than prefixing "Immutable" as the default would do.
    // This is so that if we have _FlexibleEventMention,
    // the generated implementation is FlexibleEventMention, not
    // ImmutableFlexibleEventMention
    typeImmutable = "*",
    // the template class must be prefixed with _
    typeAbstract = {"_*"},
    // make the class annotated with this package private,
    // so API users only see the generated implementation, not
    // the template
    visibility = Value.Style.ImplementationVisibility.PUBLIC)
public @interface TextGroupPublicImmutable {
}

package com.bbn.bue.common;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.annotations.Beta;

import org.immutables.value.Value;

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

/**
 * This is the text group's default style for immutable objects generated using
 * the "Immutables.org" library. Use this whenever you use {@link org.immutables.value.Value.Immutable}
 * for objects intended to be public unless you have a strong reason to do otherwise.
 */
@Beta
@Target({ElementType.PACKAGE, ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
@Value.Style(
    // use the stripped abstract type name as the immutable type name
    // rather than prefixing "Immutable" as the default would do.
    // This is so that if we have _FlexibleEventMention,
    // the generated implementation is FlexibleEventMention, not
    // ImmutableFlexibleEventMention
    typeImmutable = "*",
    // the template class must be prefixed with _
    typeAbstract = {"_*"},
    // make the class annotated with this package private,
    // so API users only see the generated implementation, not
    // the template
    visibility = Value.Style.ImplementationVisibility.PUBLIC)
@JsonSerialize
@JsonDeserialize
public @interface TextGroupPublicImmutable {
}

Make Immutables type Jackson-serializable by default


package won.protocol.jms;

import javax.jms.ConnectionFactory;

import org.apache.camel.component.jms.JmsConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * User: LEIH-NB
 * Date: 28.04.14
 */
public class WonJmsConfiguration extends JmsConfiguration
{
  private final Logger logger = LoggerFactory.getLogger(getClass());

  public WonJmsConfiguration(ConnectionFactory connectionFactory){
    super(connectionFactory);
    configureDefaultJmsConfiguration();

  }
  public void configureDefaultJmsConfiguration(){
    setTimeToLive(0);
    setDisableTimeToLive(true);
    setRequestTimeout(0);
    setAsyncConsumer(true);
    setDeliveryPersistent(false);
    setDisableReplyTo(true);
    setTimeToLive(5000);
    setTransacted(false);
    logger.info("default jms configuration setup done");
  }

  public void configureJmsConfigurationForQueues(){
    setConcurrentConsumers(5);
  }

  public void configureJmsConfigurationForTopics(){

  }

}

package won.protocol.jms;

import javax.jms.ConnectionFactory;

import org.apache.camel.component.jms.JmsConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * User: LEIH-NB
 * Date: 28.04.14
 */
public class WonJmsConfiguration extends JmsConfiguration
{
  private final Logger logger = LoggerFactory.getLogger(getClass());

  public WonJmsConfiguration(ConnectionFactory connectionFactory){
    super(connectionFactory);
    configureDefaultJmsConfiguration();

  }
  public void configureDefaultJmsConfiguration(){
    //setDisableTimeToLive(true);
    //setRequestTimeout(0);
    //setAsyncConsumer(true); //this may improve performance for most cases, but it bites us in the registration situation, when we actually want to get a result from the wonnode.
    setDeliveryPersistent(false);
    //setDisableReplyTo(true);
    setTimeToLive(5000);
    setTransacted(false);
    logger.info("default jms configuration setup done");
  }

  public void configureJmsConfigurationForQueues(){
    setConcurrentConsumers(5);
  }

  public void configureJmsConfigurationForTopics(){

  }

}

Disable async sending in Activmq

Disable async sending in Activmq

Unfortunately enabling async sending needs more work - registration
fails using this setting


package com.davidbracewell.apollo.ml.sequence;

import com.davidbracewell.apollo.ml.Learner;
import com.davidbracewell.apollo.ml.data.Dataset;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;

/**
 * The type Sequence labeler learner.
 *
 * @author David B. Bracewell
 */
public abstract class SequenceLabelerLearner extends Learner<Sequence, SequenceLabeler> {
   private static final long serialVersionUID = 1L;
   @Getter
   @Setter
   protected Decoder decoder = new BeamDecoder(5);
   @Getter
   @Setter
   protected TransitionFeature transitionFeatures = TransitionFeature.FIRST_ORDER;
   @Getter
   @Setter
   protected SequenceValidator validator = SequenceValidator.ALWAYS_TRUE;

   @Override
   public SequenceLabeler train(@NonNull Dataset<Sequence> dataset) {
      dataset.encode();
      transitionFeatures.fit(dataset);
      dataset.getEncoderPair().freeze();
      SequenceLabeler model = trainImpl(dataset);
      model.finishTraining();
      model.getFeatureEncoder().freeze();
      return model;
   }

}// END OF SequenceLabelerLearner

package com.davidbracewell.apollo.ml.sequence;

import com.davidbracewell.apollo.ml.Learner;
import com.davidbracewell.apollo.ml.data.Dataset;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;

/**
 * The type Sequence labeler learner.
 *
 * @author David B. Bracewell
 */
public abstract class SequenceLabelerLearner extends Learner<Sequence, SequenceLabeler> {
   private static final long serialVersionUID = 1L;
   @Getter
   @Setter
   protected Decoder decoder = new BeamDecoder(5);
   @Getter
   @Setter
   protected TransitionFeature transitionFeatures = TransitionFeature.FIRST_ORDER;
   @Getter
   @Setter
   protected SequenceValidator validator = SequenceValidator.ALWAYS_TRUE;

   @Override
   public SequenceLabeler train(@NonNull Dataset<Sequence> dataset) {
      dataset.encode();
      update(dataset.getEncoderPair(), dataset.getPreprocessors());
      transitionFeatures.fit(dataset);
      dataset.getEncoderPair().freeze();
      SequenceLabeler model = trainImpl(dataset);
      model.finishTraining();
      model.getFeatureEncoder().freeze();
      return model;
   }

}// END OF SequenceLabelerLearner

Fix SequenceLabelLearner to ensure it sets the preprocessors


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

public class CallAggregator {

    private static class CallPart {
        private long ts;
        private boolean isStart;

        public CallPart(long ts, boolean isStart) {
            this.ts = ts;
            this.isStart = isStart;
        }
    }

    private static class CallPartComparator implements Comparator<CallPart> {
        @Override
        public int compare(CallPart o1, CallPart o2) {
            if (o1.ts == o2.ts) {
                return 0;
            }
            return o1.ts > o2.ts ? 1 : -1;
        }
    }

    public static int max(List<Call> calls) {
        assert (calls != null);

        final List<CallPart> startAndEnds = new LinkedList<>();
        calls.forEach(call -> {
            startAndEnds.add(new CallPart(call.getStartTs(), true));
            startAndEnds.add(new CallPart(call.getEndTs(), false));
        });

        startAndEnds.sort(new CallPartComparator());

        int max = 0;
        int currentNumberOfCall = 0;
        long lastTs = -1;
        for (CallPart callPart : startAndEnds) {
            if (lastTs != callPart.ts) {
                max = Math.max(max, currentNumberOfCall);
            }
            if (callPart.isStart) {
                currentNumberOfCall++;
            } else {
                currentNumberOfCall--;
            }
        }
        max = Math.max(max, currentNumberOfCall);

        return max;
    }
}

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

public class CallAggregator {

    private static class CallPart {
        private long ts;
        private boolean isStart;

        public CallPart(long ts, boolean isStart) {
            this.ts = ts;
            this.isStart = isStart;
        }
    }

    private static class CallPartComparator implements Comparator<CallPart> {
        @Override
        public int compare(CallPart o1, CallPart o2) {
            if (o1.ts == o2.ts) {
                return o1.isStart ? 1 : -1; // the ends are before the starts !!
            }
            return o1.ts > o2.ts ? 1 : -1;
        }
    }

    public static int max(List<Call> calls) {
        assert (calls != null);

        final List<CallPart> startAndEnds = new LinkedList<>();
        calls.forEach(call -> {
            startAndEnds.add(new CallPart(call.getStartTs(), true));
            startAndEnds.add(new CallPart(call.getEndTs(), false));
        });

        startAndEnds.sort(new CallPartComparator());

        int max = 0;
        int currentNumberOfCall = 0;
        for (CallPart callPart : startAndEnds) {
            if (callPart.isStart) {
                currentNumberOfCall++;
            } else {
                currentNumberOfCall--;
            }
            max = Math.max(max, currentNumberOfCall); // because ends are before starts
        }

        return max;
    }
}

Simplify the code: while sorting the ends are placed before the starts


package org.ethereum.solidity;

import org.ethereum.solidity.compiler.CompilationResult;
import org.ethereum.solidity.compiler.SolidityCompiler;
import org.junit.Ignore;
import org.junit.Test;

import java.io.IOException;

/**
 * Created by Anton Nashatyrev on 03.03.2016.
 */
public class CompilerTest {

    @Test
    public void simpleTest() throws IOException {
        String contract =
                "contract a {" +
                "  int i1;" +
                "  function i() returns (int) {" +
                "    return i1;" +
                "  }" +
                "}";
        SolidityCompiler.Result res = SolidityCompiler.compile(
                contract.getBytes(), true, SolidityCompiler.Options.ABI, SolidityCompiler.Options.BIN, SolidityCompiler.Options.INTERFACE);
        System.out.println(res.output);
        System.out.println(res.errors);
        CompilationResult result = CompilationResult.parse(res.output);
        System.out.println(result.contracts.get("a").bin);
    }

    public static void main(String[] args) throws Exception {
        new CompilerTest().simpleTest();
    }
}

package org.ethereum.solidity;

import org.ethereum.solidity.compiler.CompilationResult;
import org.ethereum.solidity.compiler.SolidityCompiler;
import org.junit.Ignore;
import org.junit.Test;

import java.io.IOException;

/**
 * Created by Anton Nashatyrev on 03.03.2016.
 */
public class CompilerTest {

    @Test
    public void simpleTest() throws IOException {
        String contract =
                "contract a {" +
                "  int i1;" +
                "  function i() returns (int) {" +
                "    return i1;" +
                "  }" +
                "}";
        SolidityCompiler.Result res = SolidityCompiler.compile(
                contract.getBytes(), true, SolidityCompiler.Options.ABI, SolidityCompiler.Options.BIN, SolidityCompiler.Options.INTERFACE);
        System.out.println("Out: '" + res.output + "'");
        System.out.println("Err: '" + res.errors + "'");
        CompilationResult result = CompilationResult.parse(res.output);
        System.out.println(result.contracts.get("a").bin);
    }

    public static void main(String[] args) throws Exception {
        new CompilerTest().simpleTest();
    }
}

Add bit more out in test

Add bit more out in test


package org.jetbrains.debugger.memory.action;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.xdebugger.XDebugSession;
import com.sun.jdi.ReferenceType;
import org.jetbrains.debugger.memory.component.InstancesTracker;
import org.jetbrains.debugger.memory.utils.InstancesProvider;
import org.jetbrains.debugger.memory.view.ClassesTable;
import org.jetbrains.debugger.memory.view.InstancesWindow;

public class ShowNewInstancesAction extends ClassesActionBase {
  @Override
  protected boolean isEnabled(AnActionEvent e) {
    Project project = e.getProject();
    ReferenceType selectedClass = getSelectedClass(e);
    return super.isEnabled(e) && selectedClass != null &&
        project != null && InstancesTracker.getInstance(project).isTracked(selectedClass.name());
  }

  @Override
  protected void perform(AnActionEvent e) {
    XDebugSession session = getDebugSession(e);
    ReferenceType selectedClass = getSelectedClass(e);
    InstancesProvider provider = e.getData(ClassesTable.NEW_INSTANCES_PROVIDER_KEY);
    if(selectedClass != null && provider != null && session != null) {
      new InstancesWindow(session, provider, selectedClass.name()).show();
    }
  }
}

package org.jetbrains.debugger.memory.action;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.xdebugger.XDebugSession;
import com.sun.jdi.ReferenceType;
import org.jetbrains.debugger.memory.utils.InstancesProvider;
import org.jetbrains.debugger.memory.view.ClassesTable;
import org.jetbrains.debugger.memory.view.InstancesWindow;

public class ShowNewInstancesAction extends ClassesActionBase {
  @Override
  protected boolean isEnabled(AnActionEvent e) {
    XDebugSession session = getDebugSession(e);
    ReferenceType selectedClass = getSelectedClass(e);
    InstancesProvider provider = e.getData(ClassesTable.NEW_INSTANCES_PROVIDER_KEY);
    return super.isEnabled(e) && session != null && selectedClass != null && provider != null;
  }

  @Override
  protected void perform(AnActionEvent e) {
    XDebugSession session = getDebugSession(e);
    ReferenceType selectedClass = getSelectedClass(e);
    InstancesProvider provider = e.getData(ClassesTable.NEW_INSTANCES_PROVIDER_KEY);
    if(selectedClass != null && provider != null && session != null) {
      new InstancesWindow(session, provider, selectedClass.name()).show();
    }
  }
}

Fix bug when "Show New Instances" action is enabled, but tracker is not ready


/*
 * Copyright 2019 Google LLC
 *
 * 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
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.gnd.persistence.local.room;

import androidx.room.Insert;
import androidx.room.Update;
import io.reactivex.Completable;
import io.reactivex.Single;

/**
 * Base interface for DAOs that implement operations on a specific entity type.
 *
 * @param <E> the type of entity that is persisted by sub-interfaces.
 */
public interface BaseDao<E> {
  @Insert
  Completable insert(E entity);

  @Update
  Single<Integer> update(E entity);

  /**
   * Try to update the specified entity, and if it doesn't yet exist, create it.
   *
   * @param entity
   * @return Completes when the insert or update operation is complete.
   */
  default Completable insertOrUpdate(E entity) {
    return update(entity).filter(n -> n == 0).flatMapCompletable(__ -> insert(entity));
  }
}

/*
 * Copyright 2019 Google LLC
 *
 * 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
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.gnd.persistence.local.room;

import androidx.room.Insert;
import androidx.room.Update;
import io.reactivex.Completable;
import io.reactivex.Single;

/**
 * Base interface for DAOs that implement operations on a specific entity type.
 *
 * @param <E> the type of entity that is persisted by sub-interfaces.
 */
public interface BaseDao<E> {
  @Insert
  Completable insert(E entity);

  @Update
  Single<Integer> update(E entity);

  /**
   * Try to update the specified entity, and if it doesn't yet exist, create it.
   */
  default Completable insertOrUpdate(E entity) {
    return update(entity).filter(n -> n == 0).flatMapCompletable(__ -> insert(entity));
  }
}

Remove unused Javadoc block comment

Remove unused Javadoc block comment


// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// TODO: Remove this package on Vespa 7
@ExportPackage
package com.yahoo.vespaxmlparser;

import com.yahoo.osgi.annotation.ExportPackage;

// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// TODO: Remove this package on Vespa 8
@ExportPackage
package com.yahoo.vespaxmlparser;

import com.yahoo.osgi.annotation.ExportPackage;

Move TODO to Vespa 8

Move TODO to Vespa 8


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

package com.google.cloud.pubsublite;

public final class Endpoints {
  public static String dataEndpoint(CloudRegion region) {
    return region + "-pubsublite.googleapis.com/v1/data";
  }

  public static String adminEndpoint(CloudRegion region) {
    return region + "-pubsublite.googleapis.com/v1/admin";
  }

  public static String cursorEndpoint(CloudRegion region) {
    return region + "-pubsublite.googleapis.com/v1/cursor";
  }

  private Endpoints() {}
}

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

package com.google.cloud.pubsublite;

public final class Endpoints {
  public static String dataEndpoint(CloudRegion region) {
    return region.value() + "-pubsublite.googleapis.com";
  }

  public static String adminEndpoint(CloudRegion region) {
    return region.value() + "-pubsublite.googleapis.com";
  }

  public static String cursorEndpoint(CloudRegion region) {
    return region.value() + "-pubsublite.googleapis.com";
  }

  private Endpoints() {}
}

Fix endpoints to reflect their correct per-region values.


/*
 * Copyright 2015 Jan Ouwens
 *
 * 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.
 */
/**
 * Applies Eclipse's NonNullByDefault annotation to the package.
 */
@NonNullByDefault
package nl.jqno.equalsverifier.integration.extra_features.nonnull.eclipse;

import nl.jqno.equalsverifier.testhelpers.annotations.org.eclipse.jdt.annotation.NonNullByDefault;

/*
 * Copyright 2015 Jan Ouwens
 *
 * 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.
 */
/**
 * Applies Eclipse's NonNullByDefault annotation to the package.
 *
 * Actual classes in this package reside in AnnotationNonnullTypeUseTest,
 * because they're Java 8 only and need to be compiled conditionally.
 */
@NonNullByDefault
package nl.jqno.equalsverifier.integration.extra_features.nonnull.eclipse;

import nl.jqno.equalsverifier.testhelpers.annotations.org.eclipse.jdt.annotation.NonNullByDefault;

Improve Javadoc for Eclipse nonnull annotation package


package memap.messages.planning;

import com.google.gson.Gson;

import akka.basicMessages.AnswerContent;
import memap.messages.extension.NetworkType;

public class StorageMessage implements AnswerContent {

	public String id;
	public String name;

	public double operationalCostEUR;
	public double operationalCostCO2;

	public double capacity;
	public double stateOfCharge;

	public double maxLoad;
	public double maxDischarge;

	public double efficiencyCharge;
	public double efficiencyDischarge;

	public double storageLosses; //Input-Unit, mostly given as [kWh/24h] at SOC=0.75

	public NetworkType networkType;

	public String toString() {
		Gson gson = new Gson();
		String result = "";
		result = gson.toJson(this);
		return result;
	}

}

package memap.messages.planning;

import com.google.gson.Gson;

import akka.basicMessages.AnswerContent;
import memap.messages.extension.NetworkType;

public class StorageMessage implements AnswerContent {

	public String id;
	public String name;

	public double operationalCostEUR;
	public double operationalCostCO2;

	public double capacity;
	public double stateOfCharge;

	public double maxLoad;
	public double maxDischarge;

	public double efficiencyCharge;
	public double efficiencyDischarge;

	public double storageLosses;

	public double alpha;
	public double beta_to;
	public double beta_fm;

	public NetworkType networkType;

	public String toString() {
		Gson gson = new Gson();
		String result = "";
		result = gson.toJson(this);
		return result;
	}

}

Revert "Removed alphas and betas, moved to MILPProblemWithConnections"

This reverts commit 7a1bbba1b9a52e6bae8e99b85f2e0e0653a2d866.


package org.postgresql;
public class DriverClass {
public static String connectClass="org.postgresql.jdbc2.Connection";
}

package org.postgresql;
public class DriverClass {
public static String connectClass="org.postgresql.jdbc1.Connection";
}

Add res clear to example

Add res clear to example


package com.cloudant.sync.datastore;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by tomblench on 06/08/2014.
 */
public class MutableDocumentRevision implements DocumentRevision
{

    public String docId;

    // ctor with no source revision id: this revision hasn't been saved yet
    MutableDocumentRevision() {
        this.attachments = new HashMap<String, Attachment>();
        this.sourceRevisionId = null;
    }

    // ctor with revision id: this revision has been saved (eg mutable copy)
    protected MutableDocumentRevision(String sourceRevisionId) {
        this.attachments = new HashMap<String, Attachment>();
        this.sourceRevisionId = sourceRevisionId;
    }

    @Override
    public String getId() {
        return docId;
    }

    protected final String sourceRevisionId;

    @Override
    public String getRevision() {
        // hasn't been saved yet so doesn't have a rev id
        return null;
    }

    // NB the key is purely for the user's convenience and doesn't have to be the same as the attachment name
    public Map<String, Attachment> attachments;

    @Override
    public Map<String, Attachment> getAttachments() {
        return attachments;
    }

    public DocumentBody body;

    @Override
    public DocumentBody getBody() {
        return body;
    }

}

package com.cloudant.sync.datastore;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by tomblench on 06/08/2014.
 */
public class MutableDocumentRevision implements DocumentRevision
{

    public String docId;

    // ctor with no source revision id: this revision hasn't been saved yet
    public MutableDocumentRevision() {
        this.attachments = new HashMap<String, Attachment>();
        this.sourceRevisionId = null;
    }

    // ctor with revision id: this revision has been saved (eg mutable copy)
    protected MutableDocumentRevision(String sourceRevisionId) {
        this.attachments = new HashMap<String, Attachment>();
        this.sourceRevisionId = sourceRevisionId;
    }

    @Override
    public String getId() {
        return docId;
    }

    protected final String sourceRevisionId;

    @Override
    public String getRevision() {
        // hasn't been saved yet so doesn't have a rev id
        return null;
    }

    // NB the key is purely for the user's convenience and doesn't have to be the same as the attachment name
    public Map<String, Attachment> attachments;

    @Override
    public Map<String, Attachment> getAttachments() {
        return attachments;
    }

    public DocumentBody body;

    @Override
    public DocumentBody getBody() {
        return body;
    }

}

Fix bug where default constructor wasn't public


package edu.northwestern.bioinformatics.studycalendar.testing;

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

import org.springframework.context.ApplicationContext;

import javax.sql.DataSource;

/**
 * @author Rhett Sutphin
 */
public class DaoTestCase extends DbTestCase {
    private static ApplicationContext applicationContext = null;

    protected DataSource getDataSource() {
        return (DataSource) getApplicationContext().getBean("dataSource");
    }

    public ApplicationContext getApplicationContext() {
        synchronized (DaoTestCase.class) {
            if (applicationContext == null) {
                applicationContext = ContextTools.createDeployedApplicationContext();
            }
            return applicationContext;
        }
    }
}

package edu.northwestern.bioinformatics.studycalendar.testing;

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

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor;

import javax.sql.DataSource;

/**
 * @author Rhett Sutphin
 */
public class DaoTestCase extends DbTestCase {
    private static ApplicationContext applicationContext = null;
    protected final Log log = LogFactory.getLog(getClass());

    protected MockHttpServletRequest request = new MockHttpServletRequest();
    protected MockHttpServletResponse response = new MockHttpServletResponse();
    private boolean shouldFlush = true;

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

    protected void tearDown() throws Exception {
        endSession();
        findOpenSessionInViewInterceptor().setFlushModeName("FLUSH_NEVER");
        super.tearDown();
    }

    public void runBare() throws Throwable {
        setUp();
        try {
            runTest();
        } catch (Throwable throwable) {
            shouldFlush = false;
            throw throwable;
        } finally {
            tearDown();
        }
    }

    private void beginSession() {
        log.info("-- beginning DaoTestCase interceptor session --");
        findOpenSessionInViewInterceptor().preHandle(request, response, null);
    }

    private void endSession() {
        log.info("--    ending DaoTestCase interceptor session --");
        OpenSessionInViewInterceptor interceptor = findOpenSessionInViewInterceptor();
        if (shouldFlush) {
            interceptor.postHandle(request, response, null, null);
        }
        interceptor.afterCompletion(request, response, null, null);
    }

    protected void interruptSession() {
        endSession();
        log.info("-- interrupted DaoTestCase session --");
        beginSession();
    }

    private OpenSessionInViewInterceptor findOpenSessionInViewInterceptor() {
        return (OpenSessionInViewInterceptor) getApplicationContext().getBean("openSessionInViewInterceptor");
    }

    protected DataSource getDataSource() {
        return (DataSource) getApplicationContext().getBean("dataSource");
    }

    public ApplicationContext getApplicationContext() {
        synchronized (DaoTestCase.class) {
            if (applicationContext == null) {
                applicationContext = ContextTools.createDeployedApplicationContext();
            }
            return applicationContext;
        }
    }
}

Add open session in view filter support to tests

git-svn-id: 4b387fe5ada7764508e2ca96c335714e4c1692c6@38 0d517254-b314-0410-acde-c619094fa49f


package org.shipkit.internal.gradle.plugin;

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.shipkit.gradle.plugin.PluginValidatorTask;
import org.shipkit.internal.gradle.util.JavaPluginUtil;
import org.shipkit.internal.gradle.util.TaskMaker;

/**
 * This plugin validates that every plugin has a corresponding .properties file.
 *
 * Adds tasks:
 *

 *
'validatePlugins' - of type {@link PluginValidatorTask}.
 *          Validates that every plugin has a corresponding .properties file.

 *

 */
public class PluginValidationPlugin implements Plugin<Project> {

    static final String VALIDATE_PLUGINS = "validatePlugins";

    @Override
    public void apply(final Project project) {
        project.getPlugins().withId("java", plugin -> TaskMaker.task(project, VALIDATE_PLUGINS, PluginValidatorTask.class, task -> {
            task.setDescription("Validates Gradle Plugins and their properties files");
            task.setSourceSet(JavaPluginUtil.getMainSourceSet(project));
        }));
    }
}

package org.shipkit.internal.gradle.plugin;

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.plugins.JavaBasePlugin;
import org.shipkit.gradle.plugin.PluginValidatorTask;
import org.shipkit.internal.gradle.util.JavaPluginUtil;
import org.shipkit.internal.gradle.util.TaskMaker;

/**
 * This plugin validates that every plugin has a corresponding .properties file.
 *
 *

 *
Adds 'validatePlugins' task of type {@link PluginValidatorTask}.
 *          Validates that every plugin has a corresponding .properties file.
 *          New task is configured as dependency of 'check' task so that when you run 'check', the plugins are validated
 *

 *

 */
public class PluginValidationPlugin implements Plugin<Project> {

    static final String VALIDATE_PLUGINS = "validatePlugins";

    @Override
    public void apply(final Project project) {
        project.getPlugins().withId("java", plugin -> {
            TaskMaker.task(project, VALIDATE_PLUGINS, PluginValidatorTask.class, task -> {
                task.setDescription("Validates Gradle Plugins and their properties files");
                task.setSourceSet(JavaPluginUtil.getMainSourceSet(project));

                project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(task);
            });
        });
    }
}

Validate plugins with 'check' task

Validate plugins with 'check' task

Convention over configuration


package io.quarkus.jaeger.runtime.graal;

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

import io.jaegertracing.internal.JaegerSpan;
import io.jaegertracing.spi.Reporter;

@Substitute
@TargetClass(className = "io.jaegertracing.internal.reporters.LoggingReporter")
final public class Target_LoggingReporter implements Reporter {

    @Substitute
    public Target_LoggingReporter() {

    }

    @Substitute
    @Override
    public void report(JaegerSpan span) {
        System.err.println("--- not logging: " + span);
    }

    @Substitute
    @Override
    public void close() {

    }

}

package io.quarkus.jaeger.runtime.graal;

import org.jboss.logging.Logger;

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

import io.jaegertracing.internal.JaegerSpan;
import io.jaegertracing.spi.Reporter;

@Substitute
@TargetClass(className = "io.jaegertracing.internal.reporters.LoggingReporter")
final public class Target_LoggingReporter implements Reporter {

    private static final Logger LOG = Logger.getLogger(Target_LoggingReporter.class);

    @Substitute
    public Target_LoggingReporter() {

    }

    @Substitute
    @Override
    public void report(JaegerSpan span) {
        LOG.infof("Span reported: %s", span);
    }

    @Substitute
    @Override
    public void close() {

    }

}

Update Jaeger reporter to use logger

Update Jaeger reporter to use logger

Update Jaeger reporter to use proper log instead of println statement


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.fasam.projetoexemplo.entidades;

/**
 *
 * @author Aluno
 */
public class Categoria {
    String nome;
    String descrição;

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getDescrição() {
        return descrição;
    }

    public void setDescrição(String descrição) {
        this.descrição = descrição;
    }

}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.fasam.projetoexemplo.entidades;

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

/**
 *
 * @author Aluno
 */
public class Categoria {
    String nome;
    String descrição;
    List<Artigo> artigos;
     public Artigo getArtigo(Integer i){
        return artigos.get(i);
    }
    public void addArtigo(Artigo artigo){
        if(this.artigos == null){
            this.artigos = new ArrayList<Artigo>();
        }
    }
    public void remArtigo(Artigo artigo){
        if(this.artigos != null){
            this.artigos.remove(artigo);
        }
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getDescrição() {
        return descrição;
    }

    public void setDescrição(String descrição) {
        this.descrição = descrição;
    }

}

Add get e set em categoria - Informatica


/*
 * Arthur Edelstein, UCSF, 2011
 */

package org.micromanager.clojureeditor;

import org.micromanager.api.MMPlugin;
import org.micromanager.api.ScriptInterface;

public class ClojureEditorPlugin implements MMPlugin {
   public static String menuName = "Clojure editor";

   public void dispose() {
      // do nothing
   }

   public void setApp(ScriptInterface app) {
      // do nothing.
   }

   public void show() {
      clooj.core.show();
   }

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

   public String getDescription() {
      throw new UnsupportedOperationException("Not supported yet.");
   }

   public String getInfo() {
      throw new UnsupportedOperationException("Not supported yet.");
   }

   public String getVersion() {
      throw new UnsupportedOperationException("Not supported yet.");
   }

   public String getCopyright() {
      throw new UnsupportedOperationException("Not supported yet.");
   }

}

/*
 * Arthur Edelstein, UCSF, 2011
 */

package org.micromanager.clojureeditor;

import org.micromanager.api.MMPlugin;
import org.micromanager.api.ScriptInterface;

public class ClojureEditorPlugin implements MMPlugin {
   public static String menuName = "Clojure editor";

   public void dispose() {
      // do nothing
   }

   public void setApp(ScriptInterface app) {
      // do nothing.
   }

   public void show() {
      // this line does not compile:
      //clooj.core.show();
   }

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

   public String getDescription() {
      throw new UnsupportedOperationException("Not supported yet.");
   }

   public String getInfo() {
      throw new UnsupportedOperationException("Not supported yet.");
   }

   public String getVersion() {
      throw new UnsupportedOperationException("Not supported yet.");
   }

   public String getCopyright() {
      throw new UnsupportedOperationException("Not supported yet.");
   }

}

Remove line that does not compile

Remove line that does not compile

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@7511 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd


package org.apache.karaf.webconsole.core.internal;

import org.apache.wicket.Page;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.util.ListModel;

public class SidebarPanel extends Panel {

    public SidebarPanel(String id, Class<? extends Page> basePage, ListModel<Class<? extends Page>> listModel) {
        super(id, listModel);

        add(new BookmarkablePageLink<Page>("masterPageLink", basePage).add(new Label("masterPageLabel", basePage.getName())));

        add(new ListView<Class<? extends Page>>("subPageLinks", listModel) {
            @Override
            protected void populateItem(ListItem<Class<? extends Page>> item) {
                BookmarkablePageLink<Page> link = new BookmarkablePageLink<Page>("subPageLink", item.getModelObject());
                link.add(new Label("subPageLabel", item.getModelObject().getName()));
                item.add(link);
            }
        });
    }

}

package org.apache.karaf.webconsole.core.internal;

import org.apache.wicket.Page;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.util.ListModel;

public class SidebarPanel extends Panel {

    public SidebarPanel(String id, Class<? extends Page> basePage, ListModel<Class<? extends Page>> listModel) {
        super(id, listModel);

        add(new BookmarkablePageLink<Page>("masterPageLink", basePage).add(new Label("masterPageLabel", basePage.getSimpleName())));

        add(new ListView<Class<? extends Page>>("subPageLinks", listModel) {
            @Override
            protected void populateItem(ListItem<Class<? extends Page>> item) {
                Class<? extends Page> page = item.getModelObject();
                BookmarkablePageLink<Page> link = new BookmarkablePageLink<Page>("subPageLink", page);
                link.add(new Label("subPageLabel", page.getSimpleName()));
                item.add(link);
            }
        });
    }

}

Improve sidebar a bit - remove long class names from navigation

git-svn-id: e2c3038d01fb1e63d9a6e7e9a258c7088cd26e08@1160300 13f79535-47bb-0310-9956-ffa450edef68


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

import org.mutabilitydetector.cli.URLFallbackClassLoader;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.analysis.SimpleVerifier;

public class CustomClassLoadingSimpleVerifier extends SimpleVerifier {

	@Override
	protected Class<?> getClass(Type t) {

		URLFallbackClassLoader classLoader = new URLFallbackClassLoader();
		String className;

		try {
			if (t.getSort() == Type.ARRAY) {
				className = t.getDescriptor().replace('/', '.');
			} else {
				className = t.getClassName();
			}
			return classLoader.getClass(className);
		} catch (ClassNotFoundException e) {
			throw new RuntimeException(e);
		}
	}
}

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

import org.mutabilitydetector.cli.URLFallbackClassLoader;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.analysis.SimpleVerifier;

public class CustomClassLoadingSimpleVerifier extends SimpleVerifier {

	private URLFallbackClassLoader classLoader;

	public CustomClassLoadingSimpleVerifier() {
		classLoader = new URLFallbackClassLoader();
	}

	@Override
	protected Class<?> getClass(Type t) {
		String className;

		try {
			if (t.getSort() == Type.ARRAY) {
				className = t.getDescriptor().replace('/', '.');
			} else {
				className = t.getClassName();
			}
			return classLoader.getClass(className);
		} catch (ClassNotFoundException e) {
			throw new RuntimeException(e);
		}
	}
}

Improve performance of the URLFallbackClassLoader. Non-scientific stopwatch tests showed a >10% speed increase, translating to a whopping seven seconds off when analysing rt.jar.

git-svn-id: ed609ce04ec9e3c0bc25e071e87814dd6d976548@103 c7a0535c-eda6-11de-83d8-6d5adf01d787


package net.mcft.copy.betterstorage.api.crafting;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

public abstract class RecipeInputBase implements IRecipeInput {

	@Override
	public abstract int getAmount();

	@Override
	public abstract boolean matches(ItemStack stack);

	@Override
	public void craft(ItemStack input, ContainerInfo containerInfo) {
		if (input == null) return;
		input.stackSize -= getAmount();

		Item item = input.getItem();
		ItemStack containerItem = item.getContainerItemStack(input);
		boolean doesLeaveCrafting = item.doesContainerItemLeaveCraftingGrid(input);
		containerInfo.set(containerItem, doesLeaveCrafting);
	}

}

package net.mcft.copy.betterstorage.api.crafting;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

public abstract class RecipeInputBase implements IRecipeInput {

	@Override
	public abstract int getAmount();

	@Override
	public abstract boolean matches(ItemStack stack);

	@Override
	public void craft(ItemStack input, ContainerInfo containerInfo) {
		if (input == null) return;

		Item item = input.getItem();
		ItemStack containerItem = item.getContainerItemStack(input.copy());
		boolean doesLeaveCrafting = item.doesContainerItemLeaveCraftingGrid(input);
		containerInfo.set(containerItem, doesLeaveCrafting);

		input.stackSize -= getAmount();
	}

}

Fix container item crafting in crafting station


package com.sunny.grokkingalgorithms.fasttrack;

/**
 * Created by sundas on 6/17/2018.
 */
public class Poweroftwo {

  public static void main(String[] args) {

    int a = 3;
    while(a != 1){
      if(a %2 == 0){
        System.out.println("true");
        break;
      }
      a = a/2;
    }

  }
}

package com.sunny.grokkingalgorithms.fasttrack;

/**
 * Created by sundas on 6/17/2018.
 */
public class Poweroftwo {

  public static void main(String[] args) {

    int a = 3;
    while(a != 1){
      if(a %2 == 0){
        System.out.println("true");
        break;
      }
      a = a/2;
    }

    a = 4;
    int x = a&(a - 1);
    System.out.println(x == 0);
  }
}

Check if a number is power of 2

Check if a number is power of 2


package io.github.silencio_app.silencio;

import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

public class SplashActivity extends AppCompatActivity {

    private static final int SPLASH_TIME = 3000;

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

        TextView tx = (TextView)findViewById(R.id.textViewSilencio);
        Typeface custom_font = Typeface.createFromAsset(getAssets(), "fonts/Somatic-Rounded.otf");
        tx.setTypeface(custom_font);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                startActivity(intent);
                finish();
            }
        }, SPLASH_TIME);
    }

}

package io.github.silencio_app.silencio;

import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

public class SplashActivity extends AppCompatActivity {

    private static final int SPLASH_TIME = 1000;

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

        TextView tx = (TextView)findViewById(R.id.textViewSilencio);
        Typeface custom_font = Typeface.createFromAsset(getAssets(), "fonts/Somatic-Rounded.otf");
        tx.setTypeface(custom_font);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
                startActivity(intent);
                finish();
            }
        }, SPLASH_TIME);
    }

}

Fix spalsh time and start loginActivity

Fix spalsh time and start loginActivity


//
// 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 com.cloud.storage.template;

import static org.junit.Assert.fail;

import java.io.File;

import org.junit.Test;

public class LocalTemplateDownloaderTest {

    @Test
    public void localTemplateDownloaderTest() {
        String url =  "file://" + new File("pom.xml").getAbsolutePath();
        TemplateDownloader td = new LocalTemplateDownloader(null, url, "/tmp", TemplateDownloader.DEFAULT_MAX_TEMPLATE_SIZE_IN_BYTES, null);
        long bytes = td.download(true, null);
        if (!(bytes > 0)) {
            fail("Failed download");
        }
    }

}

//
// 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 com.cloud.storage.template;

import static org.junit.Assert.fail;

import java.io.File;

import org.junit.Test;

public class LocalTemplateDownloaderTest {

    @Test
    public void localTemplateDownloaderTest() {
        String url =  "file://" + new File("pom.xml").getAbsolutePath();
        TemplateDownloader td = new LocalTemplateDownloader(null, url, System.getProperty("java.io.tmpdir"), TemplateDownloader.DEFAULT_MAX_TEMPLATE_SIZE_IN_BYTES, null);
        long bytes = td.download(true, null);
        if (!(bytes > 0)) {
            fail("Failed download");
        }
    }

}

Use java.io.tmpdir instead of hardcoded /tmp


/**
 * Created by Yannick Lacaute on 17/05/17.
 * Copyright 2015-2016 the original author or authors.
 *

 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *

 * http://www.apache.org/licenses/LICENSE-2.0
 *

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.thorpora.ezdashing.sonar;

import org.springframework.context.annotation.Configuration;

import java.time.format.DateTimeFormatter;

@Configuration
public class SonarConfig {

    public static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:MM");

}

/**
 * Created by Yannick Lacaute on 17/05/17.
 * Copyright 2015-2016 the original author or authors.
 *

 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *

 * http://www.apache.org/licenses/LICENSE-2.0
 *

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.thorpora.ezdashing.sonar;

import org.springframework.context.annotation.Configuration;

import java.time.format.DateTimeFormatter;

@Configuration
public class SonarConfig {

    public static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM HH:MM");

}

Fix bug on Sonar lastUpdate (remove year in format)


/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2010(Year date of delivery) United States Government, as represented by the Secretary of Health and Human Services.  All rights reserved.
 *
 */
package gov.hhs.fha.nhinc.mpi.adapter.component;

import gov.hhs.fha.nhinc.mpilib.Patients;
import gov.hhs.fha.nhinc.patientdb.model.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author rayj
 */
public class CommonChecks {

    // MPI XML Checks

    public static boolean isSingleSearchResult(Patients patients) {
        return ((patients != null) && (patients.size() == 1));
    }

    public static boolean isMultipleSearchResult(Patients patients) {
        return ((patients != null) && (patients.size() > 1));
    }

    public static boolean isZeroSearchResult(Patients patients) {
        return ((patients == null) || (patients.size() == 0));
    }

    // MPI DB Checks

    public static boolean isSinglePerAASearchResult(List<Patient> patients) {
        boolean result = true;

        Map testMap = new HashMap();
        if (patients != null) {
            for (Patient patient : patients) {
                if (patient.getIdentifiers() != null &&
                        patient.getIdentifiers().size() > 0 &&
                        patient.getIdentifiers().get(0) != null) {
                    String orgId = patient.getIdentifiers().get(0).getOrganizationId();
                    if (testMap.containsKey(orgId)) {
                        result = false;
                        break;
                    }
                }
            }
        }

        return result;
    }

    public static boolean isZeroPerAASearchResult(List<Patient> patients) {
        return ((patients == null) || (patients.size() == 0));
    }

}

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2010(Year date of delivery) United States Government, as represented by the Secretary of Health and Human Services.  All rights reserved.
 *
 */
package gov.hhs.fha.nhinc.mpi.adapter.component;

import gov.hhs.fha.nhinc.mpilib.Patients;

/**
 *
 * @author rayj
 */
public class CommonChecks {

    public static boolean isSingleSearchResult(Patients patients) {
        return ((patients != null) && (patients.size() == 1));
    }

    public static boolean isMultipleSearchResult(Patients patients) {
        return ((patients != null) && (patients.size() > 1));
    }

    public static boolean isZeroSearchResult(Patients patients) {
        return ((patients == null) || (patients.size() == 0));
    }

}

CONNECT MPI Adapter - DB implementation - reverted: implemented MPI DB Checks; no longer needed


package com.speedment.common.codegen.internal.java.view.value;

import com.speedment.common.codegen.Generator;
import com.speedment.common.codegen.Transform;
import com.speedment.common.codegen.model.value.InvocationValue;

import java.util.Optional;

import static com.speedment.common.codegen.util.Formatting.nl;
import static com.speedment.common.codegen.util.Formatting.tab;
import static java.util.stream.Collectors.joining;

/**
 * Transforms from an {@link InvocationValue} to java code.
 *
 * @author Emil Forslund
 * @since  2.4.6
 */
public final class InvocationValueView
implements Transform<InvocationValue, String> {

    @Override
    public Optional<String> transform(Generator gen, InvocationValue model) {
        return Optional.of(
            (model.getType() == null ? "" :
                gen.on(model.getType()).get() + ".") +
            model.getValue() +
            (model.getValues().size() <= 3
                ? gen.onEach(model.getValues()).collect(joining(", ", "(", ")"))
                : gen.onEach(model.getValues()).collect(joining(
                    "," + nl() + tab(),
                    "(" + nl() + tab(),
                    nl() + ")"
                ))
            )
        );
    }
}

package com.speedment.common.codegen.internal.java.view.value;

import com.speedment.common.codegen.Generator;
import com.speedment.common.codegen.Transform;
import com.speedment.common.codegen.model.value.InvocationValue;

import java.util.Optional;

import static com.speedment.common.codegen.util.Formatting.indent;
import static com.speedment.common.codegen.util.Formatting.nl;
import static java.util.stream.Collectors.joining;

/**
 * Transforms from an {@link InvocationValue} to java code.
 *
 * @author Emil Forslund
 * @since  2.4.6
 */
public final class InvocationValueView
implements Transform<InvocationValue, String> {

    @Override
    public Optional<String> transform(Generator gen, InvocationValue model) {
        return Optional.of(
            (model.getType() == null ? "" :
                gen.on(model.getType()).get() + ".") +
            model.getValue() +
            (model.getValues().size() <= 3
                ? gen.onEach(model.getValues()).collect(joining(", ", "(", ")"))
                : ("(" + nl() + indent(gen.onEach(model.getValues())
                    .collect(joining("," + nl()))) + nl() + ")"
                )
            )
        );
    }
}

codegen: Fix minor formatting issues with new views


/*
 * 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, Flavio Fernandes
 */

package org.opendaylight.ovsdb.openstack.netvirt.api;

import java.net.InetAddress;
import java.net.InterfaceAddress;
import java.util.Set;
import java.util.UUID;

/**
 * A MultiTenantForwardingProvider provides Multi-Tenant L3 Forwarding
 */
public interface MultiTenantRouterForwardingProvider {

  void addStaticArpEntry(UUID tenantId, String macAddress, InetAddress ipAddress);

  void addIpRewriteRule(UUID tenantId, InetAddress matchAddress, InetAddress rewriteAddress);

  void addRouterInterface(UUID tenantId, String macAddress, Set<InterfaceAddress> addresses);

  void addForwardingTableEntry(UUID tenantId, InetAddress ipAddress, String macAddress);

  void addDefaultRouteEntry(UUID tenantId, String macAddress, InetAddress nextHop);

}

/*
 * 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, Flavio Fernandes
 */

package org.opendaylight.ovsdb.openstack.netvirt.api;

import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.ovsdb.openstack.netvirt.AbstractEvent;

import java.net.InetAddress;
import java.net.InterfaceAddress;
import java.util.Set;

/**
 * A MultiTenantForwardingProvider provides Multi-Tenant L3 Forwarding
 */
public interface MultiTenantRouterForwardingProvider {

    Status programStaticArpEntry(Node node, Long dpid, String segmentationId,
                                 String macAddress, InetAddress ipAddress, AbstractEvent.Action action);

    Status programIpRewriteRule(Node node, Long dpid, String segmentationId, InetAddress matchAddress,
                                InetAddress rewriteAddress, AbstractEvent.Action action);

    Status programIpRewriteExclusion(Node node, Long dpid, String segmentationId,
                                     InterfaceAddress excludedAddress, AbstractEvent.Action action);

    Status programRouterInterface(Node node, Long dpid, String segmentationId, String macAddress,
                                  Set<InterfaceAddress> addresses, AbstractEvent.Action action);

    Status programForwardingTableEntry(Node node, Long dpid, String segmentationId, InetAddress ipAddress,
                                       String macAddress, AbstractEvent.Action action);

    Status programDefaultRouteEntry(Node node, Long dpid, String segmentationId, String macAddress,
                                    InetAddress nextHop, AbstractEvent.Action action);

}

Add node and dpid information to L3 Forwarding API

Change-Id: I06186d17b3a26e262caee612d9221994adc8ca1c
Signed-off-by: Dave Tucker <38bd290b0ce167c92fc77aa50ad43e0fe89e0f98@redhat.com>


package jenkins.advancedqueue;

import hudson.model.Job;
import hudson.model.Queue;
import jenkins.advancedqueue.sorter.ItemInfo;
import jenkins.advancedqueue.sorter.QueueItemCache;
import jenkins.model.Jenkins;
import org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution;

class PriorityConfigurationPlaceholderTaskHelper {

    private static boolean placeholderTaskUsed = Jenkins.getInstance().getPlugin("workflow-durable-task-step") != null;

    boolean isPlaceholderTask(Queue.Task task) {
        return placeholderTaskUsed && task instanceof  ExecutorStepExecution.PlaceholderTask;
    }

    PriorityConfigurationCallback getPriority(ExecutorStepExecution.PlaceholderTask task, PriorityConfigurationCallback priorityCallback) {
        Job<?, ?> job = (Job<?, ?>) task.getOwnerTask();
        ItemInfo itemInfo = QueueItemCache.get().getItem(job.getName());
        itemInfo.getPriority();
        priorityCallback.setPrioritySelection(itemInfo.getPriority());
        return priorityCallback;
    }

    static boolean isPlaceholderTaskUsed() {
        return placeholderTaskUsed;
    }

}

package jenkins.advancedqueue;

import hudson.model.Job;
import hudson.model.Queue;
import jenkins.advancedqueue.sorter.ItemInfo;
import jenkins.advancedqueue.sorter.QueueItemCache;
import jenkins.model.Jenkins;
import org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution;

class PriorityConfigurationPlaceholderTaskHelper {

    boolean isPlaceholderTask(Queue.Task task) {
        return isPlaceholderTaskUsed() && task instanceof  ExecutorStepExecution.PlaceholderTask;
    }

    PriorityConfigurationCallback getPriority(ExecutorStepExecution.PlaceholderTask task, PriorityConfigurationCallback priorityCallback) {
        Job<?, ?> job = (Job<?, ?>) task.getOwnerTask();
        ItemInfo itemInfo = QueueItemCache.get().getItem(job.getName());
        itemInfo.getPriority();
        priorityCallback.setPrioritySelection(itemInfo.getPriority());
        return priorityCallback;
    }

    static boolean isPlaceholderTaskUsed() {
        return Jenkins.getInstance().getPlugin("workflow-durable-task-step") != null;
    }

}

Fix inability dynamically install Pipeline


package com.avairebot.orion.scheduler;

import com.avairebot.orion.Orion;
import com.avairebot.orion.contracts.scheduler.Job;
import net.dv8tion.jda.core.entities.Game;

public class ChangeGameJob extends Job {

    private int index = 0;

    public ChangeGameJob(Orion orion) {
        super(orion);
    }

    @Override
    public void run() {
        if (orion.config.getPlaying().size() <= index) {
            index = 0;
        }

        orion.getJDA().getPresence().setGame(
                Game.of(orion.config.getPlaying().get(index++))
        );
    }
}

package com.avairebot.orion.scheduler;

import com.avairebot.orion.Orion;
import com.avairebot.orion.contracts.scheduler.Job;
import net.dv8tion.jda.core.entities.Game;

public class ChangeGameJob extends Job {

    private int index = 0;

    public ChangeGameJob(Orion orion) {
        super(orion);
    }

    @Override
    public void run() {
        if (orion.config.getPlaying().size() <= index) {
            index = 0;
        }

        orion.getJDA().getPresence().setGame(
                Game.of(formatGame(orion.config.getPlaying().get(index++)))
        );
    }

    private String formatGame(String game) {
        game = game.replaceAll("%users%", "" + orion.getJDA().getUsers().size());
        game = game.replaceAll("%guilds%", "" + orion.getJDA().getGuilds().size());

        if (orion.getJDA().getShardInfo() != null) {
            game = game.replaceAll("%shard-id%", "" + orion.getJDA().getShardInfo().getShardId());
            game = game.replaceAll("%shard-total%", "" + orion.getJDA().getShardInfo().getShardTotal());
        }

        return game;
    }
}

Add user variables to bot game playing status


package com.elmakers.mine.bukkit.api.block;

import java.util.List;

import com.elmakers.mine.bukkit.api.entity.EntityData;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;

import com.elmakers.mine.bukkit.api.magic.Mage;

public interface UndoList extends BlockList, Comparable<UndoList> {
    public void commit();
    public void undo();
    public void undo(boolean undoEntityChanges);

    public void setScheduleUndo(int ttl);
    public int getScheduledUndo();
    public boolean bypass();
    public long getCreatedTime();
    public long getModifiedTime();
    public long getScheduledTime();
    public boolean isScheduled();

    public void prune();

    public void add(Entity entity);
    public void remove(Entity entity);
    public EntityData modify(Entity entity);
    public void add(Runnable runnable);

    public void convert(Entity entity, Block block);
    public void fall(Entity entity, Block block);
    public void explode(Entity entity, List<Block> explodedBlocks);
    public void cancelExplosion(Entity entity);

    public boolean contains(Location location, int threshold);

    public String getName();
    public Mage getOwner();
}

package com.elmakers.mine.bukkit.api.block;

import java.util.List;

import com.elmakers.mine.bukkit.api.entity.EntityData;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;

import com.elmakers.mine.bukkit.api.magic.Mage;

public interface UndoList extends BlockList, Comparable<UndoList> {
    public void commit();
    public void undo();

    public void setEntityUndo(boolean undoEntityEffects);

    public void setScheduleUndo(int ttl);
    public int getScheduledUndo();
    public boolean bypass();
    public long getCreatedTime();
    public long getModifiedTime();
    public long getScheduledTime();
    public boolean isScheduled();

    public void prune();

    public void add(Entity entity);
    public void remove(Entity entity);
    public EntityData modify(Entity entity);
    public void add(Runnable runnable);

    public void convert(Entity entity, Block block);
    public void fall(Entity entity, Block block);
    public void explode(Entity entity, List<Block> explodedBlocks);
    public void cancelExplosion(Entity entity);

    public boolean contains(Location location, int threshold);

    public String getName();
    public Mage getOwner();
}

Refactor entity effect undo control

Refactor entity effect undo control


package me.deftware.mixin.mixins;

import me.deftware.client.framework.event.events.EventWeather;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.WorldRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(WorldRenderer.class)
public class MixinWorldRenderer {

    @Inject(method = "method_22713", at = @At("HEAD"), cancellable = true)
    private void renderRain(Camera camera, CallbackInfo ci) {
        EventWeather event = new EventWeather(EventWeather.WeatherType.Rain);
        event.broadcast();
        if (event.isCanceled()) {
            ci.cancel();
        }
    }

}

package me.deftware.mixin.mixins;

import me.deftware.client.framework.event.events.EventWeather;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.render.WorldRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(WorldRenderer.class)
public class MixinWorldRenderer {

    @Inject(method = "method_22713", at = @At("HEAD"), cancellable = true)
    private void renderRain(Camera camera, CallbackInfo ci) {
        EventWeather event = new EventWeather(EventWeather.WeatherType.Rain);
        event.broadcast();
        if (event.isCanceled()) {
            ci.cancel();
        }
    }

    @Inject(method = "renderWeather", at = @At("HEAD"), cancellable = true)
    private void renderWeather(LightmapTextureManager manager, float f, double d, double e, double g, CallbackInfo ci) {
        EventWeather event = new EventWeather(EventWeather.WeatherType.Rain);
        event.broadcast();
        if (event.isCanceled()) {
            ci.cancel();
        }
    }

}

[Fix] Fix EventWeather not triggering properly


/*
 * MailMessage.java - This class holds an abstract base class for implementing a mailinglist-specific
 *                    message with required identifiers and content.
 *
 * Copyright (C) 2010 Magnus Hagander <magnus@hagander.net>
 *
 * This software is released under the BSD license.
 */
package net.hagander.mailinglistmoderator.backend;

/**
 *
 * @author Magnus Hagander <magnus@hagander.net>
 *
 *         This base class is simply a container for some common properties.
 */
public abstract class MailMessage {
	private String sender;
	private String subject;
	private String content;
	private statuslevel status = statuslevel.Defer;

	public enum statuslevel {
		Accept, Reject, Defer
	};

	public MailMessage(String sender, String subject, String content) {
		this.sender = sender;
		this.subject = subject;
		this.content = content;
	}

	public String getSender() {
		return sender;
	}

	public String getSubject() {
		return subject;
	}

	public String getContent() {
		return content;
	}

	public void setStatus(statuslevel status) {
		this.status = status;
	}

	public statuslevel getStatus() {
		return status;
	}
}

/*
 * MailMessage.java - This class holds an abstract base class for implementing a mailinglist-specific
 *                    message with required identifiers and content.
 *
 * Copyright (C) 2010 Magnus Hagander <magnus@hagander.net>
 *
 * This software is released under the BSD license.
 */
package net.hagander.mailinglistmoderator.backend;

/**
 *
 * @author Magnus Hagander <magnus@hagander.net>
 *
 *         This base class is simply a container for some common properties.
 */
public abstract class MailMessage {
	private String sender;
	private String subject;
	private String content;
	private statuslevel status = statuslevel.Defer;

	public enum statuslevel {
		Accept, Reject, Defer
	};

	public MailMessage(String sender, String subject, String content) {
		/*
		 * Create new strings to de-couple from large strings being returned
		 * in regex matches. We do this here to get it in a centralized location,
		 * even if it means we might duplicate once or twice too many.
		 * Also, limit the length of the content to 255 bytes.
		 */
		this.sender = new String(sender);
		this.subject = new String(subject);
		if (content.length() > 255)
			this.content = new String(content.substring(0,255));
		else
			this.content = new String(content);
	}

	public String getSender() {
		return sender;
	}

	public String getSubject() {
		return subject;
	}

	public String getContent() {
		return content;
	}

	public void setStatus(statuslevel status) {
		this.status = status;
	}

	public statuslevel getStatus() {
		return status;
	}
}

Create new instances of strings, and truncate length of message contents

This should drastically reduce memory consumption.

The new strings need to be created because the groups matched from regexps are
just pointers into the original string, meaning we left the whole old HTML string
around forever...


package uk.ac.ebi.fgpt.lode.utils;

/**
 * @author Simon Jupp
 * @date 21/02/2013
 * Functional Genomics Group EMBL-EBI
 */
public enum GraphQueryFormats {

    RDFXML ("RDF/XML", "application/rdf+xml"),
    N3 ("N3", "application/rdf+n3"),
    JSON ("JSON-LD", "application/rdf+json"),
    TURTLE ("TURTLE", "text/turtle");

    private final String format;
    private final String mimetype;

    private GraphQueryFormats(final String format, final String mimetype) {
	this.format = format;
	this.mimetype = mimetype;
    }

    @Override
    public String toString() {
        return format;
    }

    public String toMimeType() {
        return mimetype;
    }
}

package uk.ac.ebi.fgpt.lode.utils;

/**
 * @author Simon Jupp
 * @date 21/02/2013
 * Functional Genomics Group EMBL-EBI
 */
public enum GraphQueryFormats {

    RDFXML ("RDF/XML", "application/rdf+xml"),
    N3 ("N3", "application/rdf+n3"),
    JSON ("JSON-LD", "application/ld+json"),
    TURTLE ("TURTLE", "text/turtle");

    private final String format;
    private final String mimetype;

    private GraphQueryFormats(final String format, final String mimetype) {
	this.format = format;
	this.mimetype = mimetype;
    }

    @Override
    public String toString() {
        return format;
    }

    public String toMimeType() {
        return mimetype;
    }
}

Change MIME-type for JSON-LD graph query responses

- Addresses EBISPOT/lodestar#25 upstream and HHS/meshrdf#91 downstream


package ${packageName};

import org.springframework.bootstrap.SpringApplication;
import org.springframework.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;

@ComponentScan
@EnableAutoConfiguration
public class Application {

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

package ${packageName};

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;

@ComponentScan
@EnableAutoConfiguration
public class Application {

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

Fix packages in sample app

Fix packages in sample app


package com.swandiggy.poe4j.data.readers.value;

import com.swandiggy.poe4j.data.DatFileReader;
import org.springframework.stereotype.Service;

/**
 * Read a string value. Reads an int pointer into the variable width portion of the file. Strings are null terminated
 * and encoded as UTF-16LE.
 *
 * @author Jacob Swanson
 * @since 12/15/2015
 */
public class StringReader extends BaseValueReader<String> {

    public StringReader() {
    }

    @Override
    public boolean supports(Class clazz) {
        return clazz == String.class;
    }

    @Override
    protected String readInternal(DatFileReader reader, Class clazz) {
        int ref = reader.getBr().readInt();

        long oldPos = reader.getBr().getPosition();
        reader.getBr().setPosition(reader.getDataOffset() + ref);
        String s = reader.getBr().readString("UTF-16LE");
        reader.getBr().setPosition(oldPos);

        return s;
    }

    @Override
    public int size(Class clazz) {
        return 4;
    }
}

package com.swandiggy.poe4j.data.readers.value;

import com.swandiggy.poe4j.data.DatFileReader;
import lombok.extern.slf4j.Slf4j;

/**
 * Read a string value. Reads an int pointer into the variable width portion of the file. Strings are null terminated
 * and encoded as UTF-16LE.
 *
 * @author Jacob Swanson
 * @since 12/15/2015
 */
@Slf4j
public class StringReader extends BaseValueReader<String> {

    public StringReader() {
    }

    @Override
    public boolean supports(Class clazz) {
        return clazz == String.class;
    }

    @Override
    protected String readInternal(DatFileReader reader, Class clazz) {
        int ref = reader.getBr().readInt();

        long oldPos = reader.getBr().getPosition();
        long stringPos = reader.getDataOffset() + ref;
        if (stringPos >= reader.getFile().length()) {
            log.warn("String was at end of file eof: '{}', string ref: '{}'", reader.getFile().length(), stringPos);
            return null;
        }
        reader.getBr().setPosition(reader.getDataOffset() + ref);
        String s = reader.getBr().readString("UTF-16LE");
        reader.getBr().setPosition(oldPos);

        return s;
    }

    @Override
    public int size(Class clazz) {
        return 4;
    }
}

Add check if string is at EOF

Add check if string is at EOF


/*
 * 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.facebook.presto.hive.util;

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

public final class Types
{
    private Types() {}

    public static <A, B extends A> B checkType(A value, Class<B> target, String name)
    {
        checkNotNull(value, "%s is null", name);
        checkArgument(target.isInstance(value),
                "%s must be of type %s, not %s",
                name,
                target.getName(),
                value.getClass().getName());
        return target.cast(value);
    }
}

/*
 * 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.facebook.presto.hive.util;

import com.facebook.presto.spi.ErrorCode;
import com.facebook.presto.spi.PrestoException;

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

public final class Types
{
    private Types() {}

    public static <A, B extends A> B checkType(A value, Class<B> target, String name)
    {
        checkNotNull(value, "%s is null", name);
        checkArgument(target.isInstance(value),
                "%s must be of type %s, not %s",
                name,
                target.getName(),
                value.getClass().getName());
        return target.cast(value);
    }

    public static <A, B extends A> B checkType(A value, Class<B> target, ErrorCode errorCode, String name)
    {
        checkNotNull(value, "%s is null", name);
        if (!target.isInstance(value)) {
            throw new PrestoException(errorCode, String.format(
                    "%s must be of type %s, not %s",
                    name,
                    target.getName(),
                    value.getClass().getName()));
        }
        return target.cast(value);
    }
}

Add checkType that takes an error code

Add checkType that takes an error code


package com.nincraft.ninbot.components.twitch;

import com.github.twitch4j.helix.TwitchHelix;
import lombok.extern.log4j.Log4j2;
import lombok.val;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
@Log4j2
public class TwitchAPI {

    private TwitchHelix twitchHelix;

    public TwitchAPI(TwitchHelix twitchHelix) {
        this.twitchHelix = twitchHelix;
    }

    String getBoxArtUrl(String gameName) {
        try {
            val gameResults = twitchHelix.getGames(null, Arrays.asList(gameName), null).execute();
            if (gameResults.getGames().isEmpty()) {
                return null;
            } else {
                String boxartUrl = gameResults.getGames().get(0).getBoxArtUrl();
                return boxartUrl.replace("-{width}x{height}", "");
            }
        } catch (Exception e) {
            log.error("Failed to get boxart from Twitch API", e);
            return null;
        }
    }
}

package com.nincraft.ninbot.components.twitch;

import com.github.twitch4j.helix.TwitchHelix;
import lombok.extern.log4j.Log4j2;
import lombok.val;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
@Log4j2
public class TwitchAPI {

    private TwitchHelix twitchHelix;

    public TwitchAPI(TwitchHelix twitchHelix) {
        this.twitchHelix = twitchHelix;
    }

    String getBoxArtUrl(String gameName) {
        try {
            val gameResults = twitchHelix.getGames(null, null, Arrays.asList(gameName)).execute();
            if (gameResults.getGames().isEmpty()) {
                return null;
            } else {
                String boxartUrl = gameResults.getGames().get(0).getBoxArtUrl();
                return boxartUrl.replace("-{width}x{height}", "");
            }
        } catch (Exception e) {
            log.error("Failed to get boxart from Twitch API", e);
            return null;
        }
    }
}

Fix twitch api call for boxart

Fix twitch api call for boxart


/*
 * Copyright 2010-2013 Ning, Inc.
 * Copyright 2014 Groupon, Inc
 * Copyright 2014 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.retry.plugin.api;

import org.joda.time.DateTime;

public interface RetryPluginApi {

    /**
     *
     * @return true if retry logic should be aborted
     */
    public boolean isRetryAborted();

    /**
     *
     * @return the next date where retry should occur; null if there is no more retry
     */
    public DateTime getNextRetryDate();
}

/*
 * Copyright 2010-2013 Ning, Inc.
 * Copyright 2014 Groupon, Inc
 * Copyright 2014 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.retry.plugin.api;

import org.joda.time.DateTime;

public interface RetryPluginApi {

    /**
     *
     * @return true if retry logic should be aborted
     */
    public boolean isRetryAborted(final String externalKey);

    /**
     *
     * @return the next date where retry should occur; null if there is no more retry
     */
    public DateTime getNextRetryDate(final String externalKey);
}

Add missing key to retryPlugin apis

Add missing key to retryPlugin apis


public class InsertionSort {
    public static int[] sort(int[] array) {
        for (int i = 1; i < array.length; i++) {
            int item = array[i];
            int indexHole = i;
            while (indexHole > 0 && array[indexHole - 1] > item) {
                array[indexHole] = array[--indexHole];
            }
            array[indexHole] = item;
        }
        return array;
    }
}

public class InsertionSort {
    public static void sort(int[] array) {
        for (int i = 1; i < array.length; i++) {
            int item = array[i];
            int indexHole = i;
            while (indexHole > 0 && array[indexHole - 1] > item) {
                array[indexHole] = array[--indexHole];
            }
            array[indexHole] = item;
        }
    }
}

Fix return type of insertion sort

Fix return type of insertion sort


/*
 * 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.cloudstack.storage.command;

import com.cloud.agent.api.Answer;
import com.cloud.agent.api.to.DiskTO;

public class AttachAnswer extends Answer {
    private DiskTO disk;
    public AttachAnswer() {
        super(null);
    }

    public AttachAnswer(DiskTO disk) {
        this.setDisk(disk);
    }
    public AttachAnswer(String errMsg) {
        super(null, false, errMsg);
    }

    public DiskTO getDisk() {
        return disk;
    }

    public void setDisk(DiskTO disk) {
        this.disk = disk;
    }
}

/*
 * 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.cloudstack.storage.command;

import com.cloud.agent.api.Answer;
import com.cloud.agent.api.to.DiskTO;

public class AttachAnswer extends Answer {
    private DiskTO disk;
    public AttachAnswer() {
        super(null);
    }

    public AttachAnswer(DiskTO disk) {
        super(null);
        this.setDisk(disk);
    }
    public AttachAnswer(String errMsg) {
        super(null, false, errMsg);
    }

    public DiskTO getDisk() {
        return disk;
    }

    public void setDisk(DiskTO disk) {
        this.disk = disk;
    }
}

Fix CLOUDSTACK-2520: Invoke parent constructor to set result state to default true to avoid attachVolume error.


package org.museautomation.core.task.input;

import org.museautomation.core.task.state.*;

/**
 * @author Christopher L Merrill (see LICENSE.txt for license details)
 */
public abstract class ResolvedInputSource
    {
    public abstract String getDescription();

    public static class TaskStateSource extends ResolvedInputSource
        {
        public TaskStateSource(InterTaskState state)
            {
            _state = state;
            }

        @Override
        public String getDescription()
            {
            return "from task state " + _state.getStateDefinitionId();
            }

        public InterTaskState getState()
            {
            return _state;
            }

        private final InterTaskState _state;
        }

    public static class InputProviderSource extends ResolvedInputSource
        {
        public InputProviderSource(TaskInputProvider provider)
            {
            _provider = provider;
            }

        @Override
        public String getDescription()
            {
            return "from task input provider " + _provider.getDescription();
            }

        public TaskInputProvider getProvider()
            {
            return _provider;
            }

        private final TaskInputProvider _provider;
        }

    public static class DefaultValueSource extends ResolvedInputSource
        {
        @Override
        public String getDescription()
            {
            return "from default value ";
            }
        }
    }

package org.museautomation.core.task.input;

import org.museautomation.core.task.state.*;

/**
 * @author Christopher L Merrill (see LICENSE.txt for license details)
 */
public abstract class ResolvedInputSource
    {
    public abstract String getDescription();

    public static class TaskStateSource extends ResolvedInputSource
        {
        public TaskStateSource(InterTaskState state)
            {
            _state = state;
            }

        @Override
        public String getDescription()
            {
            return "from task state " + _state.getStateDefinitionId();
            }

        public InterTaskState getState()
            {
            return _state;
            }

        private final InterTaskState _state;
        }

    public static class InputProviderSource extends ResolvedInputSource
        {
        public InputProviderSource(TaskInputProvider provider)
            {
            _provider = provider;
            }

        @Override
        public String getDescription()
            {
            return "from task input provider " + _provider.getDescription();
            }

        public TaskInputProvider getProvider()
            {
            return _provider;
            }

        private final TaskInputProvider _provider;
        }

    @SuppressWarnings("unused")  // used in UI
    public static class UserInputSource extends ResolvedInputSource
        {
        @Override
        public String getDescription()
            {
            return "from user";
            }
        }

    public static class DefaultValueSource extends ResolvedInputSource
        {
        @Override
        public String getDescription()
            {
            return "from default value ";
            }
        }
    }

[core] ENHANCE: Add UserInputSource as a InputProviderSource


package com.rockwellcollins.atc.resolute.analysis.execution;

import java.util.Comparator;

import org.osate.aadl2.NamedElement;

public class NamedElementComparator implements Comparator<NamedElement> {
    @Override
    public int compare(NamedElement arg0, NamedElement arg1) {
        if (arg0 == arg1) {
            return 0;
        }

        int r = arg0.getName().compareToIgnoreCase(arg1.getName());
        if (r != 0) {
            return r;
        }

        r = Integer.compare(arg0.hashCode(), arg1.hashCode());
        if (r == 0) {
            throw new IllegalArgumentException("Unable to order distinct objects via hashcode");
        }
        return r;
    }
}

package com.rockwellcollins.atc.resolute.analysis.execution;

import java.util.Comparator;

import org.osate.aadl2.NamedElement;

import com.rockwellcollins.atc.resolute.analysis.values.NamedElementValue;

public class NamedElementComparator implements Comparator<NamedElement> {
    @Override
    public int compare(NamedElement arg0, NamedElement arg1) {
        if (arg0 == arg1) {
            return 0;
        }

        String text0 = new NamedElementValue(arg0).toString();
        String text1 = new NamedElementValue(arg1).toString();
        int r = text0.compareToIgnoreCase(text1);
        if (r != 0) {
            return r;
        }

        r = Integer.compare(arg0.hashCode(), arg1.hashCode());
        if (r == 0) {
            throw new IllegalArgumentException("Unable to order distinct objects via hashcode");
        }
        return r;
    }
}

Order based on name used in assurance case