hexsha stringlengths 40 40 | size int64 3 1.05M | ext stringclasses 1 value | lang stringclasses 1 value | max_stars_repo_path stringlengths 5 1.02k | max_stars_repo_name stringlengths 4 126 | max_stars_repo_head_hexsha stringlengths 40 78 | max_stars_repo_licenses list | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 5 1.02k | max_issues_repo_name stringlengths 4 114 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses list | max_issues_count float64 1 92.2k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 5 1.02k | max_forks_repo_name stringlengths 4 136 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses list | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | avg_line_length float64 2.55 99.9 | max_line_length int64 3 1k | alphanum_fraction float64 0.25 1 | index int64 0 1M | content stringlengths 3 1.05M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3e0903d8400f23c2fee7ee4e0658a95997784790 | 1,786 | java | Java | unify-web-ui/src/main/java/com/tcdng/unify/web/ui/widget/control/TitleBar.java | lateefojulari/unify-framework | b3e815b9405cbe9590292d8569ef8be68f6d473d | [
"Apache-2.0"
] | 5 | 2019-01-06T21:32:02.000Z | 2021-09-26T04:13:49.000Z | unify-web-ui/src/main/java/com/tcdng/unify/web/ui/widget/control/TitleBar.java | lateefojulari/unify-framework | b3e815b9405cbe9590292d8569ef8be68f6d473d | [
"Apache-2.0"
] | 5 | 2020-01-02T11:09:48.000Z | 2021-05-03T12:12:53.000Z | unify-web-ui/src/main/java/com/tcdng/unify/web/ui/widget/control/TitleBar.java | lateefojulari/unify-framework | b3e815b9405cbe9590292d8569ef8be68f6d473d | [
"Apache-2.0"
] | 3 | 2020-04-07T11:20:04.000Z | 2021-01-15T17:37:28.000Z | 31.333333 | 98 | 0.673572 | 3,818 | /*
* Copyright 2018-2020 The Code Department.
*
* 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.tcdng.unify.web.ui.widget.control;
import com.tcdng.unify.core.UnifyException;
import com.tcdng.unify.core.annotation.Component;
import com.tcdng.unify.core.annotation.UplAttribute;
import com.tcdng.unify.core.annotation.UplAttributes;
import com.tcdng.unify.web.ui.widget.AbstractMultiControl;
/**
* Title bar with basic controls.
*
* @author Lateef Ojulari
* @since 1.0
*/
@Component("ui-titlebar")
@UplAttributes({ @UplAttribute(name = "draggable", type = boolean.class, defaultVal = "false") })
public class TitleBar extends AbstractMultiControl {
@Override
public String getStyle() throws UnifyException {
if (getUplAttribute(boolean.class, "draggable")) {
if (getUplAttribute(String.class, "style") != null) {
return getUplAttribute(String.class, "style") + "cursor:move;";
}
return "cursor:move;";
}
return super.getStyle();
}
@Override
public boolean isLayoutCaption() {
return false;
}
@Override
protected void doOnPageConstruct() throws UnifyException {
}
}
|
3e090457517cb0279199a68a8e47a583e2de7cb6 | 2,990 | java | Java | src/main/java/com/jamesinaxx/fomo/FOMO.java | jewlexx/FOMO | e5e49f3cf246e67fc5851721ea59ec650b0088cb | [
"MIT"
] | 1 | 2022-03-23T21:12:52.000Z | 2022-03-23T21:12:52.000Z | src/main/java/com/jamesinaxx/fomo/FOMO.java | jewlexx/FOMO | e5e49f3cf246e67fc5851721ea59ec650b0088cb | [
"MIT"
] | 4 | 2021-04-21T10:10:58.000Z | 2021-05-14T03:11:35.000Z | src/main/java/com/jamesinaxx/fomo/FOMO.java | jewlexx/FOMO | e5e49f3cf246e67fc5851721ea59ec650b0088cb | [
"MIT"
] | null | null | null | 28.207547 | 117 | 0.680268 | 3,819 | package com.jamesinaxx.fomo;
import com.jamesinaxx.fomo.Discord.Discord;
import com.jamesinaxx.fomo.Minecraft.Lag;
import com.jamesinaxx.fomo.Minecraft.Minecraft;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.requests.GatewayIntent;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import javax.security.auth.login.LoginException;
import java.util.Objects;
import static com.jamesinaxx.fomo.Discord.Discord.UpdatePresence;
import static com.jamesinaxx.fomo.Discord.Discord.sendMessage;
public final class FOMO extends JavaPlugin {
public static FileConfiguration config;
public static JDA client = null;
public static TextChannel channel = null;
@Override
public void onEnable() {
// Plugin startup logic
Bukkit.getPluginManager().registerEvents(new Minecraft(), this);
Bukkit
.getServer()
.getScheduler()
.scheduleSyncRepeatingTask(this, new Lag(), 100L, 1L);
config = this.getConfig();
saveDefaultConfig();
String botToken = config.getString("token");
String channelId = config.getString("channel");
if (botToken == null || botToken.equals("TOKEN_HERE") || channelId == null || channelId.equals("CHANNEL_HERE")) {
getLogger().severe("Please update FOMO/config.yml");
Bukkit.getPluginManager().disablePlugin(this);
}
try {
client =
JDABuilder
.createLight(botToken, GatewayIntent.GUILD_MESSAGES)
.addEventListeners(new Discord())
.build();
client.awaitReady();
channel = client.getTextChannelById(Objects.requireNonNull(config.getString("channel")));
UpdatePresence();
sendMessage("[Minecraft] Server is now running!");
// Log a message that the connection was successful and log the url that is needed to invite the bot
Bukkit
.getLogger()
.info(
"[FOMO] Connected to Discord as " +
Objects.requireNonNull(client.getSelfUser().getAsTag())
);
} catch (LoginException | InterruptedException e) {
e.printStackTrace();
}
if (
Objects.requireNonNull(botToken).isEmpty() ||
Objects
.requireNonNull(this.getConfig().getString("channel"))
.isEmpty()
) {
Bukkit
.getLogger()
.severe(
"Config is not set up properly! Please double check FOMO/config.yml"
);
Bukkit.getPluginManager().disablePlugin(this);
}
getLogger().info("Successfully initialized FOMO discord bot");
getLogger().info("Successfully initialized FOMO");
}
@Override
public void onDisable() {
// Plugin shutdown logic
if (client != null) {
sendMessage("[Minecraft] Server has shut down :(");
client.shutdown();
client = null;
}
getLogger().info("Successfully shutdown FOMO");
}
}
|
3e0904d7cafc0c72c935e07f5f3a0ccfa64ea475 | 2,787 | java | Java | src/main/java/Liftoff/climbwithme/controllers/BlogController.java | MeyerMichael10/climb-with-me | c080380a3dd9effc51b1bb0ae5c2073222a55ae4 | [
"MIT"
] | 1 | 2019-08-20T23:17:24.000Z | 2019-08-20T23:17:24.000Z | src/main/java/Liftoff/climbwithme/controllers/BlogController.java | MeyerMichael10/climb-with-me | c080380a3dd9effc51b1bb0ae5c2073222a55ae4 | [
"MIT"
] | null | null | null | src/main/java/Liftoff/climbwithme/controllers/BlogController.java | MeyerMichael10/climb-with-me | c080380a3dd9effc51b1bb0ae5c2073222a55ae4 | [
"MIT"
] | null | null | null | 30.626374 | 95 | 0.686042 | 3,820 | package Liftoff.climbwithme.controllers;
import Liftoff.climbwithme.models.PartnerReq;
import Liftoff.climbwithme.models.Post;
import Liftoff.climbwithme.models.data.PartnerReqDao;
import Liftoff.climbwithme.models.data.PostDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.core.oidc.user.OidcUser;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@Controller
@RequestMapping("/")
public class BlogController{
@Autowired
private PostDao postDao;
@Autowired
private PartnerReqDao partnerReqDao;
@RequestMapping(value="")
public String index(Model model, @AuthenticationPrincipal OidcUser user) {
if (user != null) {
model.addAttribute("user", user);
}
model.addAttribute("posts", postDao.findAll());
model.addAttribute("partnerReqs", partnerReqDao.findAll());
return "blog/index";
}
@RequestMapping(value = "newPost", method = RequestMethod.GET)
public String newPost(Model model, @AuthenticationPrincipal OidcUser user) {
model.addAttribute(new Post());
model.addAttribute("user", user);
return "blog/newPost";
}
@RequestMapping(value = "newPost", method = RequestMethod.POST)
public String newPost(@ModelAttribute @Valid Post newPost,
Errors errors, @AuthenticationPrincipal OidcUser user, Model model) {
newPost.setUser(user.getNickName());
if (errors.hasErrors()) {
model.addAttribute("user", user);
return "blog/newPost";
}
postDao.save(newPost);
model.addAttribute("user", user);
return "redirect:/";
}
@RequestMapping(value = "newPartnerReq")
public String newPartnerReq(Model model, @AuthenticationPrincipal OidcUser user) {
model.addAttribute(new PartnerReq());
model.addAttribute("user", user);
return "requests/newPartnerReq";
}
@RequestMapping(value = "newPartnerReq", method = RequestMethod.POST)
public String newPartnerReq(@ModelAttribute @Valid PartnerReq newPartnerReq,
Errors errors, @AuthenticationPrincipal OidcUser user, Model model) {
newPartnerReq.setUser(user.getNickName());
if (errors.hasErrors()) {
model.addAttribute("user", user);
return "requests/newPartnerReq";
}
partnerReqDao.save(newPartnerReq);
model.addAttribute("user", user);
return "redirect:/";
}
}
|
3e090604cac96aaaa46d48bae6df544a691aecd9 | 401 | java | Java | battleship-server/battleship/src/main/java/com/isergeyam/battleship/payload/TurnRequest.java | VseMiRaki/battleship | a46b3e2689974fed9e042857b9802d87fd11d676 | [
"MIT"
] | null | null | null | battleship-server/battleship/src/main/java/com/isergeyam/battleship/payload/TurnRequest.java | VseMiRaki/battleship | a46b3e2689974fed9e042857b9802d87fd11d676 | [
"MIT"
] | 3 | 2021-03-09T22:21:06.000Z | 2022-02-26T19:48:17.000Z | battleship-server/battleship/src/main/java/com/isergeyam/battleship/payload/TurnRequest.java | VseMiRaki/battleship | a46b3e2689974fed9e042857b9802d87fd11d676 | [
"MIT"
] | 1 | 2020-05-23T16:56:01.000Z | 2020-05-23T16:56:01.000Z | 19.095238 | 68 | 0.733167 | 3,821 | package com.isergeyam.battleship.payload;
import org.springframework.data.util.Pair;
import lombok.Getter;
import lombok.Setter;
/**
* TurnRequest
*/
@Getter
@Setter
public class TurnRequest {
private String token;
private Pair<Integer, Integer> turn;
public TurnRequest(String token, Integer turn_x, Integer turn_y) {
this.token = token;
this.turn = Pair.of(turn_x, turn_y);
}
}
|
3e0906d5f5167a0fe297547b79776135fcb2ecb4 | 697 | java | Java | platform/lang-api/src/com/intellij/refactoring/rename/Renamer.java | nvartolomei/intellij-community | 1aac326dadacf65d45decc25cef21f94f7b80d69 | [
"Apache-2.0"
] | 2 | 2019-04-28T07:48:50.000Z | 2020-12-11T14:18:08.000Z | platform/lang-api/src/com/intellij/refactoring/rename/Renamer.java | nvartolomei/intellij-community | 1aac326dadacf65d45decc25cef21f94f7b80d69 | [
"Apache-2.0"
] | 1 | 2020-07-30T19:04:47.000Z | 2020-07-30T19:04:47.000Z | platform/lang-api/src/com/intellij/refactoring/rename/Renamer.java | nvartolomei/intellij-community | 1aac326dadacf65d45decc25cef21f94f7b80d69 | [
"Apache-2.0"
] | 1 | 2020-10-15T05:56:42.000Z | 2020-10-15T05:56:42.000Z | 30.304348 | 140 | 0.761836 | 3,822 | // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.refactoring.rename;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
@ApiStatus.Experimental
@ApiStatus.OverrideOnly
public interface Renamer {
/**
* @return text to be rendered in the choice popup if there are several renamers available
*/
@Nls(capitalization = Nls.Capitalization.Sentence) @NotNull String getPresentableText();
/**
* Performs rename using data obtained from context.
* May show dialogs.
*/
void performRename();
}
|
3e0906fa3e987131a0b676a061a461d49e2b8d88 | 28,822 | java | Java | src/main/java/io/hyperfoil/tools/yaup/xml/pojo/Xml.java | RedHatPerf/yaup | 21c2d46303572a4b664df620eafb833d90e5b277 | [
"Apache-2.0"
] | null | null | null | src/main/java/io/hyperfoil/tools/yaup/xml/pojo/Xml.java | RedHatPerf/yaup | 21c2d46303572a4b664df620eafb833d90e5b277 | [
"Apache-2.0"
] | 21 | 2019-09-16T17:14:21.000Z | 2021-07-19T16:40:28.000Z | src/main/java/io/hyperfoil/tools/yaup/xml/pojo/Xml.java | RedHatPerf/yaup | 21c2d46303572a4b664df620eafb833d90e5b277 | [
"Apache-2.0"
] | 4 | 2019-09-16T16:20:08.000Z | 2020-02-14T13:22:48.000Z | 38.532086 | 205 | 0.4915 | 3,823 | package io.hyperfoil.tools.yaup.xml.pojo;
import io.hyperfoil.tools.yaup.HashedLists;
import io.hyperfoil.tools.yaup.StringUtil;
import io.hyperfoil.tools.yaup.file.FileUtility;
import io.hyperfoil.tools.yaup.json.Json;
import io.hyperfoil.tools.yaup.xml.XmlOperation;
import org.apache.commons.lang3.StringEscapeUtils;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.*;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import static io.hyperfoil.tools.yaup.xml.XmlOperation.Operation;
import static io.hyperfoil.tools.yaup.xml.XmlOperation.Operation.Add;
import static io.hyperfoil.tools.yaup.xml.pojo.Xml.Type.Text;
public class Xml {
final static XLogger logger = XLoggerFactory.getXLogger(MethodHandles.lookup().lookupClass());
public static final String JSON_ATTRIBUTE_PREFIX = "@";
public static final String JSON_VALUE_KEY = "text()";
public static final int INLINE_LENGTH = 120;
public static final Xml INVALID = new Xml(Type.Invalid,null,"","");
public static final String COMMENT_PREFIX = "<!--";
public static final String END_TAG_PREFIX = "</";
public static final String START_TAG_PREFIX = "<";
public static final String COMMENT_SUFFIX = "-->";
public static final String CLOSE_TAG_SUFFIX = ">";
public static final String EMPTY_TAG_SUFFIX = "/>";
public static final String ATTRIBUTE_PREFIX="@";
public static final String ATTRIBUTE_VALUE_PREFIX="=";
public static final String ATTRIBUTE_WRAPPER="\"";
public static Xml parseFile(String path){
Xml rtrn = null;
try(InputStream stream = FileUtility.getInputStream(path)){
rtrn = parse(stream,path);
} catch (IOException e) {
e.printStackTrace();
}
if(rtrn == null){
rtrn = new Xml(Type.Document,null,"xml");
}
return rtrn;
}
public static Xml parse(String content){
return parse(new ByteArrayInputStream(content.getBytes()));
}
public static Xml parse(InputStream stream){
return parse(stream,"InputStream");
}
public static Xml parse(InputStream stream,String streamName){
Xml rtrn = new Xml(Type.Document,null,"xml");//document
Stack<Xml> parentStack = new Stack<>();
parentStack.push(rtrn);
XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
try {
XMLEventReader xmlEventReader = xmlInputFactory.createXMLEventReader(stream);
while (xmlEventReader.hasNext()) {
XMLEvent xmlEvent = xmlEventReader.nextEvent();
if(xmlEvent.isStartDocument()){
StartDocument startDocumentEvent = (StartDocument)xmlEvent;
if(startDocumentEvent.getVersion()!=null){
rtrn.setAttribute(new Xml(Type.Attribute,rtrn,"version",startDocumentEvent.getVersion()));
}
if(startDocumentEvent.encodingSet()){
rtrn.setAttribute(new Xml(Type.Attribute,rtrn,"encoding",startDocumentEvent.getCharacterEncodingScheme()));
}
if(startDocumentEvent.getSystemId()!=null){
rtrn.setAttribute(new Xml(Type.Attribute,rtrn,""));
}
if(startDocumentEvent.standaloneSet()){
rtrn.setAttribute(new Xml(Type.Attribute,rtrn,"standalone",startDocumentEvent.isStandalone()?"yes":"no"));
}
}
if(xmlEvent.isStartElement()){
StartElement startElement = xmlEvent.asStartElement();
String newElementName = startElement.getName().getLocalPart();
if(!startElement.getName().getPrefix().isEmpty()){
newElementName = startElement.getName().getPrefix()+":"+newElementName;
}
Xml newElement = new Xml(Type.Tag,parentStack.peek(),newElementName);
for(Iterator<Namespace> namespaceIterator = startElement.getNamespaces(); namespaceIterator.hasNext();){
Namespace namespace = namespaceIterator.next();
String namespaceName = namespace.getName().getLocalPart();
String namespacePrefix = namespace.getPrefix();
if(namespacePrefix.isEmpty()){
namespacePrefix="xmlns";
}else{
namespacePrefix="xmlns:"+namespacePrefix;
}
String namespaceValue = namespace.getNamespaceURI();
Xml newAttribute = new Xml(Type.Attribute,newElement,namespacePrefix,namespaceValue);
newElement.setAttribute(newAttribute);
}
for(Iterator attributeIterator = startElement.getAttributes(); attributeIterator.hasNext();){
Attribute attribute = (Attribute)attributeIterator.next();
String attributeName = attribute.getName().getLocalPart();
String attributePrefix = attribute.getName().getPrefix();
if(attributePrefix!=null && !attributePrefix.isEmpty()){
attributeName = attribute.getName().getPrefix()+":"+attributeName;
}
Xml newAttribute = new Xml(Type.Attribute,newElement,attributeName);
newAttribute.setValue(attribute.getValue());
newElement.setAttribute(newAttribute);
}
parentStack.peek().addChild(newElement);
parentStack.push(newElement);
}else if(xmlEvent.isCharacters()){
String value = xmlEvent.asCharacters().getData().trim();
if(!value.isEmpty()) {
Xml textElement = new Xml(Text, parentStack.peek(),"#text");
textElement.setValue(xmlEvent.asCharacters().getData());
parentStack.peek().addChild(textElement);
}
}else if (xmlEvent.isEndElement()){
parentStack.pop();
}else if (xmlEvent.isEndDocument()){
}
}
}catch (XMLStreamException ex) {
logger.error("XMLSException "+ex.getMessage()+" for "+streamName+"\n "+parentStack.stream().map(e->e.getName()+" "+e.getType()+" "+e.getChildren().size()).collect(Collectors.joining("\n ")));
//e.printStackTrace();
}
return rtrn;
}
public enum Type {Invalid,Document,Tag,Attribute,Comment,Text}
private String name;
private String value;
private Type type;
private Map<String,Xml> attributes;
private ArrayList<Xml> allChildren;
private ArrayList<Xml> tagChildren;
private ArrayList<Xml> textChildren;
private HashedLists<String,Xml> namedTagChildren;
private Xml parent;
int tagIndex=-1;
int namedIndex =-1;
private Xml(Type type, Xml parent, String name){
this(type,parent, name,null);
}
private Xml(Type type,Xml parent, String name, String value){
this.type = type;
this.parent = parent;
this.name=name;
this.value=value;
this.attributes = new LinkedHashMap<>();
this.allChildren = new ArrayList<>();
this.tagChildren = new ArrayList<>();
this.namedTagChildren = new HashedLists<>();
this.textChildren = new ArrayList<>();
}
public Xml get(String search) {
//detect simple attribute or child search and use attribute / firstChild
if (!search.contains("/") && !search.contains("[") && search.startsWith("@")) {
//just an attribute
return attribute(search.substring(1));
} else if ( !search.contains("@") && search.lastIndexOf("/")<=0 && !search.contains("[")) {
//just a tag
return firstChild(search);
} else {
List<Xml> list = getAll(search);
return list.isEmpty() ? new Xml(Type.Invalid,null,"") : list.get(0);
}
}
public List<Xml> getAll(String search){
if(!search.contains("@") && !search.contains("/") && !search.contains("[")){
return Collections.unmodifiableList(namedTagChildren.get(search));
}else {
XmlPath path = XmlPath.parse(search);
List<Xml> rtrn = path.getMatches(this);
return rtrn;
}
}
public void addChild(Xml child){
if(!child.exists()){
return;
}
if(child.isAttribute()){
setAttribute(child);
}else{
if(child.isDocument()){
if(child.tagChildren.size()>0){
child = child.tagChildren.get(0);
}
}
allChildren.add(child);
child.parent = this;
if (child.getType().equals(Text)) {
textChildren.add(child);
addValue(child.getValue());
} else if (child.getType().equals(Type.Tag)) {
int tagIndex = tagChildren.size();
tagChildren.add(child);
int namedIndex = namedTagChildren.get(child.getName()).size();
namedTagChildren.put(child.getName(), child);
child.setIndexes(tagIndex, namedIndex);
}
}
}
public void setAttribute(Xml child){
if(!child.exists()){
return;
}
int index = attributes.size();
Xml previous = attributes.put(child.getName(),child);
child.parent=this;
child.type = Type.Attribute;
}
public boolean hasAttribute(String name){
return attributes.containsKey(name);
}
public void removeAttribute(String name){
if(hasAttribute(name)){
attributes.remove(name);
}
}
public void removeChild(Xml child){
allChildren.remove(child);
if(child.isText()){
resetTextValue();
}else if (child.isTag()){
tagChildren.remove(child);
}else if (child.isAttribute()){
removeAttribute(child.getName());
}
}
public void removeChild(int index){
allChildren.remove(index);
}
private void setIndexes(int tagIndex,int namedIndex){
this.tagIndex = tagIndex;
this.namedIndex = namedIndex;
}
int tagIndex(){return tagIndex;}
int namedIndex(){return namedIndex;}
private Type getType(){return type;}
public String getName(){return name;}
public String getValue(){
return hasValue()?value:"";
}
Xml getValueXml(){
//TODO should this be detached from parent so it cannot attempt to modify?
return new Xml(Text,null,"#text",getValue());
}
public boolean hasValue(){return value!=null;}
private void addValue(String value){
if(this.value==null){
this.value="";
}
this.value += value;
}
public void setValue(String value){
this.value = value;
}
public Xml parent(String tagName){
Xml rtrn = new Xml(Type.Invalid,null,tagName);
Xml target = this.parent;
while(!rtrn.exists() && target!=null){
if(tagName.equals(target.getName())){
rtrn = target;
}
}
return rtrn;
}
public Xml parent(){return parent;}
private void clearText(){
Iterator<Xml> childIter = allChildren.iterator();
while(childIter.hasNext()){
Xml child = childIter.next();
if(child.isText()){
childIter.remove();
}
}
value = "";
}
private void resetTextValue(){
value = "";
allChildren.forEach(child->{
if(child.isText()){
addValue(child.getValue());
}
});
}
private void clear(){
tagChildren.clear();
allChildren.clear();
value = "";
}
public List<Xml> getChildren(){
return Collections.unmodifiableList(tagChildren);
}
public Xml firstChild(String tagName){
if(isDocument() && !tagChildren.isEmpty() && !tagName.equals(tagChildren.get(0).getName())){
return tagChildren.get(0).firstChild(tagName);
}
Xml rtrn = new Xml(Type.Invalid,this,tagName);
if(!exists()){
return rtrn;
}else{
for(int i=0; i<tagChildren.size() && !rtrn.exists();i++){
Xml child = tagChildren.get(i);
if(tagName.equals(child.getName())){
rtrn = child;
break;
}
}
}
return rtrn;
}
public static Object convertString(String input){
if(input.matches("-?\\d{1,18}")){
return Long.parseLong(input);
}else if (input.matches("-?\\d*(?:\\.\\d+)?")){
return Double.parseDouble(input);
}
return input;
}
private List<Xml> allChildren(){
return Collections.unmodifiableList(allChildren);
}
public Xml attribute(String name){
if(isDocument() && !tagChildren.isEmpty() ){
return tagChildren.get(0).attribute(name);
}
if(!exists()){
return new Xml(Type.Invalid,this,name);
}
return attributes.containsKey(name)
? attributes.get(name)
: new Xml(Type.Invalid,this,name);
}
public Map<String,Xml> getAttributes(){
return Collections.unmodifiableMap(attributes);
}
public Json toJson(){
return toJson(JSON_ATTRIBUTE_PREFIX,JSON_VALUE_KEY,true);
}
public Json toJson(String attributePrefix,String valueKey,boolean convertNumbers){
Json rtrn = new Json();
Stack<Json> jsonTodo = new Stack<>();
Stack<Xml> xmlTodo = new Stack<>();
jsonTodo.push(rtrn);
xmlTodo.push(this);
while(!jsonTodo.isEmpty()){
Json json = jsonTodo.pop();
Xml xml = xmlTodo.pop();
xml.getAttributes().forEach((name,valueXml)->{
json.set(attributePrefix+name,convertNumbers ? Xml.convertString(valueXml.getValue()) : valueXml.getValue());
});
if(xml.hasValue()){
json.set(valueKey,convertNumbers ? Xml.convertString(xml.getValue()) : xml.getValue());
}
xml.getChildren().forEach(childXml->{
//Json(false) to prevent Json.add from treating it as an array for subsequent adds
Json child = new Json(false);
json.add(childXml.getName(),child);
jsonTodo.push(child);
xmlTodo.push(childXml);
});
}
return rtrn;
}
public boolean exists(){return !Type.Invalid.equals(getType());}
public boolean isDocument(){
return getType().equals(Type.Document);
}
public boolean isAttribute(){
return getType().equals(Type.Attribute);
}
public boolean isTag(){
return getType().equals(Type.Tag);
}
public boolean isText(){
return getType().equals(Text);
}
public void attributeWalk(Consumer<Xml> toWalk){
attributes.values().forEach(toWalk);
for(Xml child : getChildren()){
child.attributeWalk(toWalk);
}
}
public void childWalk(Consumer<Xml> toWalk){
toWalk.accept(this);
for(Xml child : allChildren()){
child.childWalk(toWalk);
}
}
public String apply(String xmlOperation){
XmlOperation toApply =XmlOperation.parse(xmlOperation);
return apply(toApply);
}
public String apply(XmlOperation xmlOperation){
if(!exists()){
return null;
}
StringBuilder rtrn = new StringBuilder();
XmlPath xmlPath = XmlPath.parse(xmlOperation.getPath());
List<Xml> found = Collections.EMPTY_LIST;
Operation opp = xmlOperation.getOperation();
String value = xmlOperation.getValue();
found = xmlPath.getMatches(this);
if(found.isEmpty()){
if(xmlOperation.isAdd() || xmlOperation.isSet()){
xmlPath = xmlPath.copy();
XmlPath tail = xmlPath.getTail();
tail.drop();
if(XmlPath.Type.Attribute.equals(tail.getType())){
//change to add and re-try only if tail doesn't have children
if(!tail.hasChildren() && xmlOperation.isSet()){
opp = Add;
value = ATTRIBUTE_PREFIX+tail.getName()+Xml.ATTRIBUTE_VALUE_PREFIX+xmlOperation.getValue();
found = xmlPath.getMatches(this);
}
}else if (XmlPath.Type.Tag.equals(tail.getType())){
if(xmlOperation.isSet()){
opp = Add;
StringBuilder sb = new StringBuilder();
sb.append("<");
sb.append(tail.getName());
if(tail.hasChildren()){
for(XmlPath child : tail.getChildren()){
if(XmlPath.Type.Start.equals(child.getType())){
child = child.getNext();
}
if(XmlPath.Type.Attribute.equals(child.getType())){
sb.append(" ");
sb.append(child.getName());
sb.append(Xml.ATTRIBUTE_VALUE_PREFIX);
sb.append(StringUtil.quote(child.getValue()));
}else{
logger.error("cannot build ADD out of child "+child);
sb.delete(0,sb.length());
break;
}
}
}
sb.append(">");
if(sb.length()>1){
sb.append(value);
sb.append("</");
sb.append(tail.getName());
sb.append(">");
value = sb.toString();
}
found = xmlPath.getMatches(this);
}
}else{
logger.error("unsupported type = "+tail.getType());
}
}else{
}
}
String finalValue = value.trim();
if(!found.isEmpty()){
switch (opp){
case None:
found.forEach(x->{
if(rtrn.length()>0){
rtrn.append(System.lineSeparator());
}
switch (x.getType()){
case Text:
case Attribute:
rtrn.append(x.getValue());
break;
default:
if(x.hasValue()){
rtrn.append(x.getValue());
}else {
rtrn.append(x.documentString());
}
}
});
break;
case Set:
found.forEach(x->{
if(x.isAttribute()){
x.setValue(finalValue);
}else if (x.isTag()){
if(finalValue.startsWith(START_TAG_PREFIX)){
Xml toSet = Xml.parse(finalValue);
x.clear();
x.addChild(toSet);
}else{
x.clearText();
Xml toSet = new Xml(Text,x,"#text",finalValue);
x.addChild(toSet);
}
}else if (x.isText()){
x.setValue(finalValue);
if(x.parent()!=null){
x.parent().resetTextValue();
}
}else{
logger.error("Unsupported XMl type: cannot SET "+x+" to "+finalValue);
}
});
break;
case Add:
found.forEach(x->{
if(x.isAttribute()){
x.setValue(x.getValue()+finalValue);
}else if (x.isTag()){
Xml toAdd;
if(finalValue.startsWith(START_TAG_PREFIX)){
toAdd = Xml.parse(finalValue);
x.addChild(toAdd);
}else if (finalValue.startsWith(ATTRIBUTE_PREFIX)) {
String attrName = finalValue.substring(1);
String attrValue = "";
if(attrName.contains(ATTRIBUTE_VALUE_PREFIX)){
int index = attrName.indexOf(ATTRIBUTE_VALUE_PREFIX);
if(attrName.length()>index+1) {
attrValue = attrName.substring(index + 1).trim();
}
attrName = attrName.substring(0,index).trim();
}
toAdd = new Xml(Type.Attribute,x,attrName,StringUtil.removeQuotes(attrValue));
x.setAttribute(toAdd);
}else{
toAdd = new Xml(Text,x,"#text",finalValue);
x.addChild(toAdd);
}
}else{
logger.error("Unsupported XMl type: cannot ADD "+x+" to "+finalValue);
}
});
break;
case Delete:
found.forEach(x->{
if(x.hasParent()){
if(x.isAttribute()){
x.parent().removeAttribute(x.getName());
}else if (x.isTag()){
x.parent().removeChild(x);
}else if (x.isText()){
x.parent().removeChild(x);
}else {
logger.error("Unsupported XMl type: cannot DELETE "+x);
}
}
});
break;
default:
logger.error("unsupported opp "+opp+" on "+xmlPath.toString());
}
}
if(rtrn.toString().isEmpty() && found.size()>0){
found.forEach(x->{
if(rtrn.length()>0){
rtrn.append(System.lineSeparator());
}
switch (x.getType()){
case Text:
case Attribute:
rtrn.append(x.getValue());
break;
default:
if(x.hasValue()){
rtrn.append(x.getValue());
}else {
rtrn.append(x.documentString());
}
}
});
}
return rtrn.toString();
}
private boolean hasParent() {return parent!=null;}
@Override
public String toString(){
return isDocument() ? "?xml" : (getName()+":"+value);
}
public String documentString(){
return documentString(4);
}
public String documentString(int indent){
boolean includeDocument = getType() == Type.Document ? hasAttribute("version") : true;
return documentString(indent,includeDocument);
}
public String documentString(int indent,boolean includeDocument){
StringBuilder rtrn = new StringBuilder();
append(rtrn,0,indent,includeDocument);
return rtrn.toString();
}
private void pad(StringBuilder sb,int amount){
if(amount>0){
sb.append(String.format("%"+amount+"s",""));
}
}
private void append(StringBuilder sb,int indent,int increment,boolean includeDocument){
if(!type.equals(Type.Document)) {
pad(sb,indent);
}
switch (type){
case Attribute:
sb.append(getValue());
break;
case Text:
sb.append(getValue());
break;
case Document:
if(includeDocument) {
sb.append(START_TAG_PREFIX);
sb.append("?");
sb.append(getName());
for (Xml attribute : getAttributes().values()) {
sb.append(" ");
sb.append(attribute.getName());
sb.append(ATTRIBUTE_VALUE_PREFIX);
sb.append(ATTRIBUTE_WRAPPER);
sb.append(attribute.getValue());
sb.append(ATTRIBUTE_WRAPPER);
}
sb.append("?");
sb.append(CLOSE_TAG_SUFFIX);
if (increment > 0) {
sb.append(System.lineSeparator());
}
}
for (Xml child : getChildren()) {
child.append(sb, indent, increment, includeDocument);
}
break;
case Tag:
sb.append(START_TAG_PREFIX);
sb.append(getName());
for (Xml attribute : getAttributes().values()){
sb.append(" ");
sb.append(attribute.getName());
sb.append(ATTRIBUTE_VALUE_PREFIX);
sb.append(ATTRIBUTE_WRAPPER);
sb.append(StringEscapeUtils.escapeXml11(attribute.getValue()));
//sb.append(attribute.getValue());
sb.append(ATTRIBUTE_WRAPPER);
}
if(allChildren().isEmpty() && getValue().isEmpty()){
sb.append(EMPTY_TAG_SUFFIX);
}else{
sb.append(CLOSE_TAG_SUFFIX);
if(tagChildren.isEmpty() && allChildren.stream().mapToInt(x->x.getValue().length()).sum() < INLINE_LENGTH){//only text, maybe one line?
for (Xml child : allChildren()) {
sb.append(child.getValue());
}
sb.append(END_TAG_PREFIX);
sb.append(getName());
sb.append(CLOSE_TAG_SUFFIX);
}else {
for (Xml child : allChildren()) {
if (increment > 0) {
sb.append(System.lineSeparator());
}
child.append(sb, indent + increment, increment, includeDocument);
}
if(increment>0){
sb.append(System.lineSeparator());
}
pad(sb,indent);
sb.append(END_TAG_PREFIX);
sb.append(getName());
sb.append(CLOSE_TAG_SUFFIX);
}
}
break;
case Comment:
sb.append(COMMENT_PREFIX);
sb.append(getValue());
sb.append(COMMENT_SUFFIX);
break;
default:
}
}
}
|
3e0907b5ccf17ef4fa536466ff6901fb3df687e7 | 392 | java | Java | java/shrine/app/src/main/java/com/google/codelabs/mdc/java/shrine/api/CoronaApiService.java | maxappdev/CoronaApp | be7560a00216a3937826631bc92fab73c5f60ff2 | [
"Apache-2.0"
] | null | null | null | java/shrine/app/src/main/java/com/google/codelabs/mdc/java/shrine/api/CoronaApiService.java | maxappdev/CoronaApp | be7560a00216a3937826631bc92fab73c5f60ff2 | [
"Apache-2.0"
] | null | null | null | java/shrine/app/src/main/java/com/google/codelabs/mdc/java/shrine/api/CoronaApiService.java | maxappdev/CoronaApp | be7560a00216a3937826631bc92fab73c5f60ff2 | [
"Apache-2.0"
] | null | null | null | 28 | 101 | 0.829082 | 3,824 | package com.google.codelabs.mdc.java.shrine.api;
import com.google.codelabs.mdc.java.shrine.api.model.Country;
import com.google.codelabs.mdc.java.shrine.api.model.DailyReportByCountry;
import java.io.IOException;
import java.text.ParseException;
public interface CoronaApiService {
DailyReportByCountry getDailyReportByCountry(Country country) throws IOException, ParseException;
}
|
3e0907bf56552170f2d3a3fac18206f466fcbf9f | 1,859 | java | Java | lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/UnaryOperatorKind.java | mcdolding/olingo-odata4 | a3318beed39dd92d887a953a07cf815693df8188 | [
"Apache-2.0"
] | 138 | 2015-02-08T03:40:55.000Z | 2022-03-26T21:32:04.000Z | lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/UnaryOperatorKind.java | mcdolding/olingo-odata4 | a3318beed39dd92d887a953a07cf815693df8188 | [
"Apache-2.0"
] | 30 | 2016-02-23T15:59:21.000Z | 2022-03-09T13:23:29.000Z | lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/UnaryOperatorKind.java | mcdolding/olingo-odata4 | a3318beed39dd92d887a953a07cf815693df8188 | [
"Apache-2.0"
] | 195 | 2015-01-07T09:00:44.000Z | 2022-03-31T08:42:32.000Z | 26.557143 | 93 | 0.699301 | 3,825 | /*
* 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.olingo.server.api.uri.queryoption.expression;
/**
* Enumeration of supported unary operators<br>
* For the semantic of these operators please see the ODATA specification for URL conventions
*/
public enum UnaryOperatorKind {
/**
* Minus operator
*/
MINUS("-"),
/**
* not operator
*/
NOT("not");
private String syntax;
/**
* Constructor for enumeration value
* @param Syntax used in the URI
*/
private UnaryOperatorKind(final String syntax) {
this.syntax = syntax;
}
/**
* @return URI syntax for that operator kind
*/
@Override
public String toString() {
return syntax;
}
/**
* URI syntax to enumeration value
* @param operator Operator in the syntax used in the URI
* @return Operator kind which represents the given syntax
*/
public static UnaryOperatorKind get(final String operator) {
for (UnaryOperatorKind op : UnaryOperatorKind.values()) {
if (op.toString().equals(operator)) {
return op;
}
}
return null;
}
}
|
3e09094cb370bced0d8b774caf93aafa5ee27d1f | 542 | java | Java | src/main/java/no/fint/model/administrasjon/arkiv/Skjerming.java | FINTmodels/fint-arkiv-model-java | bfba2d28ba90d62132fc3aa61951752e8b25aefe | [
"MIT"
] | null | null | null | src/main/java/no/fint/model/administrasjon/arkiv/Skjerming.java | FINTmodels/fint-arkiv-model-java | bfba2d28ba90d62132fc3aa61951752e8b25aefe | [
"MIT"
] | null | null | null | src/main/java/no/fint/model/administrasjon/arkiv/Skjerming.java | FINTmodels/fint-arkiv-model-java | bfba2d28ba90d62132fc3aa61951752e8b25aefe | [
"MIT"
] | null | null | null | 21.68 | 61 | 0.785978 | 3,826 | // Built from tag arkiv
package no.fint.model.administrasjon.arkiv;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.*;
import no.fint.model.FintComplexDatatypeObject;
@Data
@NoArgsConstructor
@EqualsAndHashCode
@ToString
public class Skjerming implements FintComplexDatatypeObject {
public enum Relasjonsnavn {
SKJERMINGSHJEMMEL,
TILGANGSRESTRIKSJON
}
}
|
3e0909809771cf41dff6517a975f5d895a29e88d | 2,147 | java | Java | okhttp/src/main/java/okhttp3/internal/http/RequestLine.java | Clark-jhx/okhttp | 9430c68f4afe409c5c9041573bb341271c278c44 | [
"Apache-2.0"
] | 81 | 2018-01-05T09:00:56.000Z | 2022-02-06T13:55:51.000Z | okhttp/src/main/java/okhttp3/internal/http/RequestLine.java | ciceromsjr/okhttp | ad7a1c862cf51d41ded54351572bb4e827f00757 | [
"Apache-2.0"
] | 3 | 2018-03-29T04:04:44.000Z | 2018-04-28T05:36:08.000Z | okhttp/src/main/java/okhttp3/internal/http/RequestLine.java | ciceromsjr/okhttp | ad7a1c862cf51d41ded54351572bb4e827f00757 | [
"Apache-2.0"
] | 25 | 2018-01-05T09:01:08.000Z | 2020-11-23T09:17:43.000Z | 33.030769 | 100 | 0.692129 | 3,827 | /*
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package okhttp3.internal.http;
import java.net.HttpURLConnection;
import java.net.Proxy;
import okhttp3.HttpUrl;
import okhttp3.Request;
public final class RequestLine {
private RequestLine() {
}
/**
* Returns the request status line, like "GET / HTTP/1.1". This is exposed to the application by
* {@link HttpURLConnection#getHeaderFields}, so it needs to be set even if the transport is
* HTTP/2.
*/
public static String get(Request request, Proxy.Type proxyType) {
StringBuilder result = new StringBuilder();
result.append(request.method());
result.append(' ');
if (includeAuthorityInRequestLine(request, proxyType)) {
result.append(request.url());
} else {
result.append(requestPath(request.url()));
}
result.append(" HTTP/1.1");
return result.toString();
}
/**
* Returns true if the request line should contain the full URL with host and port (like "GET
* http://android.com/foo HTTP/1.1") or only the path (like "GET /foo HTTP/1.1").
*/
private static boolean includeAuthorityInRequestLine(Request request, Proxy.Type proxyType) {
return !request.isHttps() && proxyType == Proxy.Type.HTTP;
}
/**
* Returns the path to request, like the '/' in 'GET / HTTP/1.1'. Never empty, even if the request
* URL is. Includes the query component if it exists.
*/
public static String requestPath(HttpUrl url) {
String path = url.encodedPath();
String query = url.encodedQuery();
return query != null ? (path + '?' + query) : path;
}
}
|
3e0909eb4a9ff3a6734dc062a287b8ab15319060 | 1,238 | java | Java | app/src/main/java/com/bzh/floodview/model/floodsituation/Submenu.java | bizehao/FloodViewing | 60a350b14d411f4fb67fcd41488dd7814a9efa3f | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/bzh/floodview/model/floodsituation/Submenu.java | bizehao/FloodViewing | 60a350b14d411f4fb67fcd41488dd7814a9efa3f | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/bzh/floodview/model/floodsituation/Submenu.java | bizehao/FloodViewing | 60a350b14d411f4fb67fcd41488dd7814a9efa3f | [
"Apache-2.0"
] | null | null | null | 19.650794 | 96 | 0.613893 | 3,828 | package com.bzh.floodview.model.floodsituation;
import java.util.LinkedHashMap;
//子项菜单
public class Submenu {
private String itemName;
private int imgId;
private int sign;// 1进入二级菜单 2进入一级菜单 3尚未开发完成
private LinkedHashMap<String,Integer> subMap;
public Submenu() {
}
public Submenu(String itemName, int imgId) {
this.itemName = itemName;
this.imgId = imgId;
}
public Submenu(String itemName, int imgId, int sign, LinkedHashMap<String,Integer> subMap) {
this.itemName = itemName;
this.imgId = imgId;
this.sign = sign;
this.subMap = subMap;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public int getImgId() {
return imgId;
}
public void setImgId(int imgId) {
this.imgId = imgId;
}
public int getSign() {
return sign;
}
public void setSign(int sign) {
this.sign = sign;
}
public LinkedHashMap<String, Integer> getSubMap() {
return subMap;
}
public void setSubMap(LinkedHashMap<String, Integer> subMap) {
this.subMap = subMap;
}
}
|
3e090a0cfcc7dfe84d3b3a8af0bc42b4ace92dcd | 3,216 | java | Java | src/main/java/com/luckystar/advent2021/Advent04.java | velxeor/adventofcode | d140ee8328003e79fbd2e0997cc7a8adf0e59ab2 | [
"Apache-2.0"
] | 1 | 2018-03-07T17:18:22.000Z | 2018-03-07T17:18:22.000Z | src/main/java/com/luckystar/advent2021/Advent04.java | velxeor/adventofcode | d140ee8328003e79fbd2e0997cc7a8adf0e59ab2 | [
"Apache-2.0"
] | null | null | null | src/main/java/com/luckystar/advent2021/Advent04.java | velxeor/adventofcode | d140ee8328003e79fbd2e0997cc7a8adf0e59ab2 | [
"Apache-2.0"
] | null | null | null | 31.529412 | 122 | 0.498756 | 3,829 | package com.luckystar.advent2021;
import com.luckystar.InputLoader;
import java.util.*;
import java.util.stream.IntStream;
/**
* Created by Alexey Matveev.
*/
public class Advent04 {
public static void main(String[] args) {
String input = InputLoader.readInput("2021/input_4.txt");
String[] split = input.split("\r\n");
int[] numbers = Arrays.stream(split[0].split(",")).mapToInt(Integer::parseInt).toArray();
List<Board> boards = new ArrayList<>();
for (int i=2; i<split.length; i++) {
int k = 0;
Board board = new Board();
boards.add(board);
while (k < 5) {
String[] split1 = split[i].trim().split("\\s+");
int[] row = Arrays.stream(split1).mapToInt(Integer::parseInt).toArray();
board.addRow(k, row);
k++;
i++;
}
}
// lets do this
ArrayList<Integer> winningBoards = new ArrayList<>();
for (int number : numbers) {
for (Board board : boards) {
board.newNumberCalled(number);
if (!board.won && board.checkVictory()) {
winningBoards.add(board.calculateNonMatchedSum() * number);
board.won = true;
}
}
}
System.out.println("Winning boards size: " + winningBoards.size());
System.out.println("First winning: " + winningBoards.get(0));
System.out.println("Last winning: " + winningBoards.get(winningBoards.size() - 1));
}
}
class Board {
int[][] data = new int[5][];
int[][] checked = new int[5][];
boolean won = false;
void addRow(int index, int[] row) {
this.data[index] = row;
this.checked[index] = new int[row.length];
}
void newNumberCalled(int num) {
for (int i=0; i < data.length; i++) {
int[] row = this.data[i];
for (int j=0; j < row.length; j++) {
int r = row[j];
if (r == num) {
this.checked[i][j] = 1;
}
}
}
}
boolean checkVictory() {
// row
for (int i=0; i < checked.length; i++) {
int[] row = this.checked[i];
boolean rowMatched = Arrays.stream(row).allMatch(v -> v == 1);
if (rowMatched) {
return true;
}
}
// col
int[] counter = new int[5];
for (int i=0; i < checked.length; i++) {
int[] row = this.checked[i];
for (int j=0; j < row.length; j++) {
if (checked[i][j] == 1) {
counter[j]++;
}
}
}
boolean colMatched = Arrays.stream(counter).anyMatch(v -> v == 5);
return colMatched;
}
int calculateNonMatchedSum() {
int[] checkeds = Arrays.stream(this.checked).flatMapToInt(Arrays::stream).toArray();
int[] datas = Arrays.stream(this.data).flatMapToInt(Arrays::stream).toArray();
return IntStream.range(0, datas.length).mapToObj(i -> checkeds[i] == 0 ? datas[i] : 0).reduce(Integer::sum).get();
}
}
|
3e090ab9f95c620b0d63734d2e8f2a00023f8d17 | 9,124 | java | Java | src/main/java/com/genesys/internal/provisioning/model/InboundData.java | GenesysPureEngage/provisioning-lib-java | 90c88cd404275cf2e4f259e6b52a6dcc47d2971d | [
"MIT"
] | null | null | null | src/main/java/com/genesys/internal/provisioning/model/InboundData.java | GenesysPureEngage/provisioning-lib-java | 90c88cd404275cf2e4f259e6b52a6dcc47d2971d | [
"MIT"
] | null | null | null | src/main/java/com/genesys/internal/provisioning/model/InboundData.java | GenesysPureEngage/provisioning-lib-java | 90c88cd404275cf2e4f259e6b52a6dcc47d2971d | [
"MIT"
] | null | null | null | 32.688172 | 605 | 0.701864 | 3,830 | /*
* Provisioning API
* The provisioning service will be used to create objects in configuration server in a way that is consistent with the BEC model. The \"users\" resource will be used to perform CRUD operations on config server person objects. Note that this API will extend the low level configuration server API to add additional functionality that will allow persons to be created in a way that makes them immediately useable in BEC. Operations on this resource may result in other configuration objects being modified as well.
*
* OpenAPI spec version: 192.168.127.12.4963
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package com.genesys.internal.provisioning.model;
import java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
/**
* InboundData
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2022-03-03T19:44:33.854Z")
public class InboundData {
@SerializedName("name")
private String name = null;
@SerializedName("maxMessageSize")
private Integer maxMessageSize = null;
@SerializedName("mailbox")
private String mailbox = null;
@SerializedName("password")
private String password = null;
@SerializedName("host")
private String host = null;
@SerializedName("port")
private Integer port = null;
@SerializedName("connectionSecurity")
private String connectionSecurity = null;
@SerializedName("type")
private String type = null;
@SerializedName("enabled")
private Boolean enabled = null;
public InboundData name(String name) {
this.name = name;
return this;
}
/**
* The name of an inbound corporate mailbox.
* @return name
**/
@ApiModelProperty(required = true, value = "The name of an inbound corporate mailbox. ")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public InboundData maxMessageSize(Integer maxMessageSize) {
this.maxMessageSize = maxMessageSize;
return this;
}
/**
* The maximum size (in MB) of an incoming message.
* @return maxMessageSize
**/
@ApiModelProperty(value = "The maximum size (in MB) of an incoming message. ")
public Integer getMaxMessageSize() {
return maxMessageSize;
}
public void setMaxMessageSize(Integer maxMessageSize) {
this.maxMessageSize = maxMessageSize;
}
public InboundData mailbox(String mailbox) {
this.mailbox = mailbox;
return this;
}
/**
* The login name associated with the POP/IMAP account.
* @return mailbox
**/
@ApiModelProperty(value = "The login name associated with the POP/IMAP account. ")
public String getMailbox() {
return mailbox;
}
public void setMailbox(String mailbox) {
this.mailbox = mailbox;
}
public InboundData password(String password) {
this.password = password;
return this;
}
/**
* The password associated with this account.
* @return password
**/
@ApiModelProperty(value = "The password associated with this account. ")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public InboundData host(String host) {
this.host = host;
return this;
}
/**
* The host name or IP address of the corporate email server on which the account resides.
* @return host
**/
@ApiModelProperty(value = "The host name or IP address of the corporate email server on which the account resides. ")
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public InboundData port(Integer port) {
this.port = port;
return this;
}
/**
* The port number for connecting to the corporate email server.
* @return port
**/
@ApiModelProperty(value = "The port number for connecting to the corporate email server. ")
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public InboundData connectionSecurity(String connectionSecurity) {
this.connectionSecurity = connectionSecurity;
return this;
}
/**
* Specifies how the connection to the corporate email server is secured. If set to `start-tls`, the Provisioning API uses the STARTTLS command (if supported by the server) to switch to a TLS-protected connection before issuing any login commands. If a TLS connection is not available, a plain-text connection is used. If set to `start-tls-required`, the API uses the STARTTLS command and if a TLS connection is not available, the connection is aborted. If set to `ssl-tls`, the API uses Secure Sockets Layer (SSL) encryption when connecting to the corporate email server.
* @return connectionSecurity
**/
@ApiModelProperty(value = "Specifies how the connection to the corporate email server is secured. If set to `start-tls`, the Provisioning API uses the STARTTLS command (if supported by the server) to switch to a TLS-protected connection before issuing any login commands. If a TLS connection is not available, a plain-text connection is used. If set to `start-tls-required`, the API uses the STARTTLS command and if a TLS connection is not available, the connection is aborted. If set to `ssl-tls`, the API uses Secure Sockets Layer (SSL) encryption when connecting to the corporate email server. ")
public String getConnectionSecurity() {
return connectionSecurity;
}
public void setConnectionSecurity(String connectionSecurity) {
this.connectionSecurity = connectionSecurity;
}
public InboundData type(String type) {
this.type = type;
return this;
}
/**
* The protocol used to retrieve incoming messages from the corporate email server. Possible values are `POP3`, `IMAP`, or `EWS`.
* @return type
**/
@ApiModelProperty(value = "The protocol used to retrieve incoming messages from the corporate email server. Possible values are `POP3`, `IMAP`, or `EWS`. ")
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public InboundData enabled(Boolean enabled) {
this.enabled = enabled;
return this;
}
/**
* Specifies if the inbound client is enabled.
* @return enabled
**/
@ApiModelProperty(value = "Specifies if the inbound client is enabled. ")
public Boolean isEnabled() {
return enabled;
}
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
InboundData inboundData = (InboundData) o;
return Objects.equals(this.name, inboundData.name) &&
Objects.equals(this.maxMessageSize, inboundData.maxMessageSize) &&
Objects.equals(this.mailbox, inboundData.mailbox) &&
Objects.equals(this.password, inboundData.password) &&
Objects.equals(this.host, inboundData.host) &&
Objects.equals(this.port, inboundData.port) &&
Objects.equals(this.connectionSecurity, inboundData.connectionSecurity) &&
Objects.equals(this.type, inboundData.type) &&
Objects.equals(this.enabled, inboundData.enabled);
}
@Override
public int hashCode() {
return Objects.hash(name, maxMessageSize, mailbox, password, host, port, connectionSecurity, type, enabled);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class InboundData {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" maxMessageSize: ").append(toIndentedString(maxMessageSize)).append("\n");
sb.append(" mailbox: ").append(toIndentedString(mailbox)).append("\n");
sb.append(" password: ").append(toIndentedString(password)).append("\n");
sb.append(" host: ").append(toIndentedString(host)).append("\n");
sb.append(" port: ").append(toIndentedString(port)).append("\n");
sb.append(" connectionSecurity: ").append(toIndentedString(connectionSecurity)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
|
3e090b7ebcf18a440d4347a8a22588590bb863b6 | 804 | java | Java | common-auth/src/main/java/io/github/acgs/cms/token/Tokens.java | acgs-org/acgs-cms-spring-cloud | 8934679d10ce9339d6728f5bcd0b5c9f019255a3 | [
"Apache-2.0"
] | null | null | null | common-auth/src/main/java/io/github/acgs/cms/token/Tokens.java | acgs-org/acgs-cms-spring-cloud | 8934679d10ce9339d6728f5bcd0b5c9f019255a3 | [
"Apache-2.0"
] | null | null | null | common-auth/src/main/java/io/github/acgs/cms/token/Tokens.java | acgs-org/acgs-cms-spring-cloud | 8934679d10ce9339d6728f5bcd0b5c9f019255a3 | [
"Apache-2.0"
] | null | null | null | 18.272727 | 60 | 0.54602 | 3,831 | package io.github.acgs.cms.token;
/**
* <p>
* 双令牌模型类
* </p>
*
* @author TierneyJohn@ACGS
* <p>
* file created on 2022/1/30
* </p>
*/
public class Tokens {
/** 访问令牌 */
private String accessToken;
/** 刷新令牌 */
private String refreshToken;
public Tokens() {}
public Tokens(String accessToken, String refreshToken) {
this.accessToken = accessToken;
this.refreshToken = refreshToken;
}
public String getAccessToken() {
return accessToken;
}
public String getRefreshToken() {
return refreshToken;
}
@Override
public String toString() {
return "Tokens{" +
"accessToken='" + accessToken + '\'' +
", refreshToken='" + refreshToken + '\'' +
'}';
}
}
|
3e090bc9eea4e36b4aa3a29c8f5e2a81b06e0e70 | 92 | java | Java | offer/src/main/java/com/java/study/algorithm/zuo/fsenior/class01/Code04_DistinctSubseq.java | seawindnick/javaFamily | d8a6cf8b185e98d6e60961e306a4bbeb4e7360dc | [
"MIT"
] | 1 | 2020-12-02T03:14:19.000Z | 2020-12-02T03:14:19.000Z | offer/src/main/java/com/java/study/algorithm/zuo/fsenior/class01/Code04_DistinctSubseq.java | seawindnick/javaFamily | d8a6cf8b185e98d6e60961e306a4bbeb4e7360dc | [
"MIT"
] | 1 | 2021-05-08T18:03:22.000Z | 2021-05-08T18:03:22.000Z | offer/src/main/java/com/java/study/algorithm/zuo/fsenior/class01/Code04_DistinctSubseq.java | seawindnick/javaFamily | d8a6cf8b185e98d6e60961e306a4bbeb4e7360dc | [
"MIT"
] | null | null | null | 23 | 53 | 0.836957 | 3,832 | package com.java.study.algorithm.zuo.fsenior.class01;
public class Code04_DistinctSubseq{
} |
3e090be73791511d75c6a73d112617142dfb966f | 379 | java | Java | src/main/java/pl/kskowronski/data/service/egeria/ek/EkGroupCodeRepo.java | ClaudePlos/nap-portal-pg | fabb884eab0aad4278e41d243851ec53f2a512d9 | [
"Unlicense"
] | null | null | null | src/main/java/pl/kskowronski/data/service/egeria/ek/EkGroupCodeRepo.java | ClaudePlos/nap-portal-pg | fabb884eab0aad4278e41d243851ec53f2a512d9 | [
"Unlicense"
] | null | null | null | src/main/java/pl/kskowronski/data/service/egeria/ek/EkGroupCodeRepo.java | ClaudePlos/nap-portal-pg | fabb884eab0aad4278e41d243851ec53f2a512d9 | [
"Unlicense"
] | null | null | null | 27.071429 | 77 | 0.823219 | 3,833 | package pl.kskowronski.data.service.egeria.ek;
import org.springframework.data.jpa.repository.JpaRepository;
import pl.kskowronski.data.entity.egeria.ek.EkGroupCode;
import java.util.List;
import java.util.Optional;
public interface EkGroupCodeRepo extends JpaRepository<EkGroupCode, String> {
Optional<List<EkGroupCode>> findAllByGkDgKodOrderByGkNumer(String dgKod);
}
|
3e090d85cbfeaa7f9da6217a0bc728363f0ef6fc | 1,693 | java | Java | pocRefRes/src/com/test/servlet/TestRef.java | sortidocop/referenceTomcatPOC | b93b3e70fa26c4cef4fbe6881bf515b64510fe60 | [
"MIT"
] | null | null | null | pocRefRes/src/com/test/servlet/TestRef.java | sortidocop/referenceTomcatPOC | b93b3e70fa26c4cef4fbe6881bf515b64510fe60 | [
"MIT"
] | null | null | null | pocRefRes/src/com/test/servlet/TestRef.java | sortidocop/referenceTomcatPOC | b93b3e70fa26c4cef4fbe6881bf515b64510fe60 | [
"MIT"
] | null | null | null | 30.781818 | 89 | 0.664501 | 3,834 | package com.test.servlet;
import java.io.IOException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class TestRef
*/
@WebServlet({ "/TestRef", "/testref" })
public class TestRef extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public TestRef() {
super();
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.getWriter().append("Served at: ").append(request.getContextPath());
try {
final Context initCtx = new InitialContext();
final Context envCtx = (Context) initCtx.lookup("java:comp/env");
final Object obj = envCtx.lookup("jms/DTestQueue");
System.err.println(obj);
} catch (final NamingException e) {
e.printStackTrace();
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
|
3e090d95fd9927d818e9cddc777c02072e869355 | 3,947 | java | Java | sdk/src/test/java/com/hedera/hashgraph/sdk/Mocker.java | rickyrodmac/hedera-sdk-java | 66805c18cd5f578171a97ed3ba8cdcb24ffb6004 | [
"Apache-2.0"
] | null | null | null | sdk/src/test/java/com/hedera/hashgraph/sdk/Mocker.java | rickyrodmac/hedera-sdk-java | 66805c18cd5f578171a97ed3ba8cdcb24ffb6004 | [
"Apache-2.0"
] | null | null | null | sdk/src/test/java/com/hedera/hashgraph/sdk/Mocker.java | rickyrodmac/hedera-sdk-java | 66805c18cd5f578171a97ed3ba8cdcb24ffb6004 | [
"Apache-2.0"
] | null | null | null | 37.235849 | 172 | 0.593362 | 3,835 | package com.hedera.hashgraph.sdk;
import com.hedera.hashgraph.sdk.proto.*;
import io.grpc.MethodDescriptor;
import io.grpc.Server;
import io.grpc.ServerMethodDefinition;
import io.grpc.ServerServiceDefinition;
import io.grpc.ServiceDescriptor;
import io.grpc.Status;
import io.grpc.inprocess.InProcessServerBuilder;
import io.grpc.stub.ServerCalls;
import java8.util.function.Function;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
public class Mocker implements AutoCloseable {
private static final PrivateKey PRIVATE_KEY = PrivateKey.fromString("302e020100300506032b657004220420d45e1557156908c967804615af59a000be88c7aa7058bfcbe0f46b16c28f887d");
private final List<ServiceDescriptor> services = List.of(
CryptoServiceGrpc.getServiceDescriptor(),
FileServiceGrpc.getServiceDescriptor(),
SmartContractServiceGrpc.getServiceDescriptor(),
ConsensusServiceGrpc.getServiceDescriptor(),
TokenServiceGrpc.getServiceDescriptor()
);
private final List<List<Object>> responses;
private final List<Server> servers = new ArrayList<>();
public final Client client;
Mocker(List<List<Object>> responses) {
this.responses = responses;
var network = new HashMap<String, AccountId>(responses.size());
for (var i = 0; i < responses.size(); i++) {
var index = new AtomicInteger();
var response = responses.get(i);
var name = InProcessServerBuilder.generateName();
var nodeAccountId = new AccountId(3 + i);
var builder = InProcessServerBuilder.forName(name);
network.put("in-process:" + name, nodeAccountId);
for (var service : services) {
var descriptor = ServerServiceDefinition.builder(service);
for (MethodDescriptor<?, ?> method : service.getMethods()) {
var methodDefinition = ServerMethodDefinition.create((MethodDescriptor<Object, Object>) method,
ServerCalls.asyncUnaryCall((request, responseObserver) -> {
var responseIndex = index.getAndIncrement();
if (responseIndex >= response.size()) {
responseObserver.onError(Status.Code.ABORTED.toStatus().asRuntimeException());
return;
}
var r = response.get(responseIndex);
if (r instanceof Function<?, ?>){
r = ((Function<Object, Object>) r).apply(request);
}
if (r instanceof Throwable) {
responseObserver.onError((Throwable) r);
} else {
responseObserver.onNext(r);
responseObserver.onCompleted();
}
})
);
descriptor.addMethod(methodDefinition);
}
builder.addService(descriptor.build());
}
try {
this.servers.add(builder.directExecutor().build().start());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
this.client = Client.forNetwork(network).setOperator(new AccountId(1800), PRIVATE_KEY);
}
public static Mocker withResponses(List<List<Object>> responses) {
return new Mocker(responses);
}
public void close() throws TimeoutException, InterruptedException {
client.close();
for (var server : servers) {
server.shutdown();
server.awaitTermination();
}
}
}
|
3e090f562b4e8037c73f42e969af47e2d7e555ac | 2,663 | java | Java | core/metamodel/src/main/java/uk/co/objectconnexions/expressiveobjects/core/progmodel/facets/object/ignore/annotation/RemoveProgrammaticOrIgnoreAnnotationMethodsFacetFactory.java | rcm2001/expressive-objects | a5ced6694cfb2daf24ba09c94cc4e1864384224c | [
"Apache-2.0"
] | null | null | null | core/metamodel/src/main/java/uk/co/objectconnexions/expressiveobjects/core/progmodel/facets/object/ignore/annotation/RemoveProgrammaticOrIgnoreAnnotationMethodsFacetFactory.java | rcm2001/expressive-objects | a5ced6694cfb2daf24ba09c94cc4e1864384224c | [
"Apache-2.0"
] | null | null | null | core/metamodel/src/main/java/uk/co/objectconnexions/expressiveobjects/core/progmodel/facets/object/ignore/annotation/RemoveProgrammaticOrIgnoreAnnotationMethodsFacetFactory.java | rcm2001/expressive-objects | a5ced6694cfb2daf24ba09c94cc4e1864384224c | [
"Apache-2.0"
] | null | null | null | 41.609375 | 153 | 0.755163 | 3,836 | /*
* 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 uk.co.objectconnexions.expressiveobjects.core.progmodel.facets.object.ignore.annotation;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import uk.co.objectconnexions.expressiveobjects.applib.annotation.Ignore;
import uk.co.objectconnexions.expressiveobjects.applib.annotation.Programmatic;
import uk.co.objectconnexions.expressiveobjects.core.metamodel.facetapi.FeatureType;
import uk.co.objectconnexions.expressiveobjects.core.metamodel.facetapi.MethodRemover;
import uk.co.objectconnexions.expressiveobjects.core.metamodel.facets.Annotations;
import uk.co.objectconnexions.expressiveobjects.core.metamodel.facets.FacetFactoryAbstract;
public class RemoveProgrammaticOrIgnoreAnnotationMethodsFacetFactory extends FacetFactoryAbstract {
public RemoveProgrammaticOrIgnoreAnnotationMethodsFacetFactory() {
super(FeatureType.OBJECTS_ONLY);
}
@Override
public void process(final ProcessClassContext processClassContext) {
removeIgnoredMethods(processClassContext.getCls(), processClassContext);
}
@SuppressWarnings("deprecation")
private void removeIgnoredMethods(final Class<?> cls, final MethodRemover methodRemover) {
if (cls == null) {
return;
}
final Method[] methods = cls.getMethods();
for (final Method method : methods) {
removeAnnotatedMethods(methodRemover, method, Ignore.class);
removeAnnotatedMethods(methodRemover, method, Programmatic.class);
}
}
private static <T extends Annotation> void removeAnnotatedMethods(final MethodRemover methodRemover, final Method method, Class<T> annotationClass) {
if (!Annotations.isAnnotationPresent(method, annotationClass)) {
return;
}
methodRemover.removeMethod(method);
}
}
|
3e090fbd21bae8f3f069b7abee6e7412bbdeaa5c | 1,686 | java | Java | src/test/java/r48/tests/R2kSerializationTest.java | rohkea/gabien-app-r48 | 890853f608134522573dca70267439033a2d1579 | [
"CC0-1.0"
] | 21 | 2017-06-08T15:51:07.000Z | 2022-02-02T01:35:51.000Z | src/test/java/r48/tests/R2kSerializationTest.java | rohkea/gabien-app-r48 | 890853f608134522573dca70267439033a2d1579 | [
"CC0-1.0"
] | 55 | 2017-07-29T08:05:57.000Z | 2022-02-13T16:44:28.000Z | src/test/java/r48/tests/R2kSerializationTest.java | rohkea/gabien-app-r48 | 890853f608134522573dca70267439033a2d1579 | [
"CC0-1.0"
] | 2 | 2021-06-12T13:38:56.000Z | 2022-03-30T00:00:39.000Z | 36.652174 | 214 | 0.656584 | 3,837 | /*
* gabien-app-r48 - Editing program for various formats
* Written starting in 2016 by contributors (see CREDITS.txt)
* To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
* You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
package r48.tests;
import gabien.TestKickstart;
import org.junit.Assert;
import org.junit.Test;
import r48.AppMain;
import r48.io.IObjectBackend;
import java.io.IOException;
/**
* Created on December 02, 2018.
*/
public class R2kSerializationTest {
@Test
public void testFullIOStack() throws IOException {
TestKickstart.kickstart("RAM/", "UTF-8", "R2K/");
String[] fileDefs = new String[] {
"hello.lmu",
"world.ldb",
"and.lmt",
"you.lsd",
};
// Save it, but skip past most of ObjectDB since it will not be queried in future & it uses UI on failure.
AppMain.objectDB.getObject("hello.lmu", "RPG::Map").save();
AppMain.objectDB.getObject("world.ldb", "RPG::Database").save();
AppMain.objectDB.getObject("and.lmt", "RPG::MapTree").save();
AppMain.objectDB.getObject("you.lsd", "RPG::Save").save();
// Kills off the old ObjectDB
TestKickstart.resetODB();
for (String s : fileDefs) {
IObjectBackend.ILoadedObject i = AppMain.objectDB.getObject(s, null);
Assert.assertNotNull(i);
}
}
}
|
3e0910260e88b28f30089b8cbe120a2e8be380c0 | 1,412 | java | Java | beecomb-common/src/main/java/io/github/icodegarden/beecomb/common/executor/ExecuteJobResult.java | icodegarden/beecomb | aa29906ea57ac72aa3bcc108b90e3bda35161054 | [
"Apache-2.0"
] | null | null | null | beecomb-common/src/main/java/io/github/icodegarden/beecomb/common/executor/ExecuteJobResult.java | icodegarden/beecomb | aa29906ea57ac72aa3bcc108b90e3bda35161054 | [
"Apache-2.0"
] | null | null | null | beecomb-common/src/main/java/io/github/icodegarden/beecomb/common/executor/ExecuteJobResult.java | icodegarden/beecomb | aa29906ea57ac72aa3bcc108b90e3bda35161054 | [
"Apache-2.0"
] | null | null | null | 21.074627 | 85 | 0.712465 | 3,838 | package io.github.icodegarden.beecomb.common.executor;
import java.io.Serializable;
import java.util.Objects;
import org.springframework.util.Assert;
import io.github.icodegarden.commons.lang.annotation.Length;
/**
*
* @author Fangfang.Xu
*
*/
public class ExecuteJobResult implements Serializable {
private static final long serialVersionUID = -6248807678193840548L;
@Length(max = 65535)
private String executeReturns;
/**
* 任务是否结束
*/
private boolean end;
public String getExecuteReturns() {
return executeReturns;
}
public void setExecuteReturns(@Length(max = 65535) String executeReturns) {
if (executeReturns != null) {
Assert.isTrue(executeReturns.length() <= 65535, "executeReturns must lte 65535");
}
this.executeReturns = executeReturns;
}
public boolean isEnd() {
return end;
}
public void setEnd(boolean end) {
this.end = end;
}
@Override
public int hashCode() {
return Objects.hash(end, executeReturns);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ExecuteJobResult other = (ExecuteJobResult) obj;
return end == other.end && Objects.equals(executeReturns, other.executeReturns);
}
@Override
public String toString() {
return "ExecuteJobResult [executeReturns=" + executeReturns + ", end=" + end + "]";
}
}
|
3e09110df671a7544bb57ddb49b76887327cd3aa | 991 | java | Java | dcat-api-jena-core/src/main/java/org/aksw/dcat/ap/plugin/JenaPluginDcatAp.java | SmartDataAnalytics/ckan-deploy | 40bbcfa963b1100bb89c7db46b21d7dc0000db03 | [
"Apache-2.0"
] | null | null | null | dcat-api-jena-core/src/main/java/org/aksw/dcat/ap/plugin/JenaPluginDcatAp.java | SmartDataAnalytics/ckan-deploy | 40bbcfa963b1100bb89c7db46b21d7dc0000db03 | [
"Apache-2.0"
] | null | null | null | dcat-api-jena-core/src/main/java/org/aksw/dcat/ap/plugin/JenaPluginDcatAp.java | SmartDataAnalytics/ckan-deploy | 40bbcfa963b1100bb89c7db46b21d7dc0000db03 | [
"Apache-2.0"
] | null | null | null | 29.147059 | 75 | 0.727548 | 3,839 | package org.aksw.dcat.ap.plugin;
import org.aksw.dcat.ap.binding.jena.domain.impl.RdfDcatApAgent;
import org.aksw.dcat.ap.binding.jena.domain.impl.RdfDcatApDataset;
import org.aksw.dcat.ap.binding.jena.domain.impl.RdfDcatApDistributionImpl;
import org.aksw.jenax.reprogen.core.JenaPluginUtils;
import org.apache.jena.enhanced.BuiltinPersonalities;
import org.apache.jena.enhanced.Personality;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.sys.JenaSubsystemLifecycle;
public class JenaPluginDcatAp
implements JenaSubsystemLifecycle {
public void start() {
JenaPluginDcatAp.init();
}
@Override
public void stop() {
}
public static void init() {
init(BuiltinPersonalities.model);
}
public static void init(Personality<RDFNode> p) {
JenaPluginUtils.registerResourceClasses(
RdfDcatApDataset.class,
RdfDcatApDistributionImpl.class,
RdfDcatApAgent.class);
}
}
|
3e091145a77e86633eecb52135af49d2abd15c58 | 5,462 | java | Java | core/src/test/java/org/apache/calcite/util/PermutationTestCase.java | sreev/incubator-calcite | fbe69824ffb13f847d1db6e26f0030ddec7b0e8c | [
"Apache-2.0"
] | 2,984 | 2015-10-29T03:04:33.000Z | 2022-03-31T09:56:30.000Z | core/src/test/java/org/apache/calcite/util/PermutationTestCase.java | sreev/incubator-calcite | fbe69824ffb13f847d1db6e26f0030ddec7b0e8c | [
"Apache-2.0"
] | 1,374 | 2015-10-28T03:21:38.000Z | 2022-03-30T06:23:43.000Z | core/src/test/java/org/apache/calcite/util/PermutationTestCase.java | sreev/incubator-calcite | fbe69824ffb13f847d1db6e26f0030ddec7b0e8c | [
"Apache-2.0"
] | 1,736 | 2015-10-27T20:18:37.000Z | 2022-03-31T06:37:04.000Z | 29.365591 | 75 | 0.639326 | 3,840 | /*
* 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.calcite.util;
import org.apache.calcite.jdbc.JavaTypeFactoryImpl;
import org.apache.calcite.rel.core.Project;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.sql.type.SqlTypeName;
import com.google.common.collect.ImmutableList;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
/**
* Unit test for {@link Permutation}.
*/
class PermutationTestCase {
@Test void testOne() {
final Permutation perm = new Permutation(4);
assertEquals(
"[0, 1, 2, 3]",
perm.toString());
assertEquals(
4,
perm.size());
perm.set(0, 2);
assertEquals(
"[2, 1, 0, 3]",
perm.toString());
perm.set(1, 0);
assertEquals(
"[2, 0, 1, 3]",
perm.toString());
final Permutation invPerm = perm.inverse();
assertEquals(
"[1, 2, 0, 3]",
invPerm.toString());
// changing perm doesn't change inverse
perm.set(0, 0);
assertEquals(
"[0, 2, 1, 3]",
perm.toString());
assertEquals(
"[1, 2, 0, 3]",
invPerm.toString());
}
@Test void testTwo() {
final Permutation perm = new Permutation(new int[]{3, 2, 0, 1});
assertFalse(perm.isIdentity());
assertEquals(
"[3, 2, 0, 1]",
perm.toString());
Permutation perm2 = (Permutation) perm.clone();
assertEquals(
"[3, 2, 0, 1]",
perm2.toString());
assertTrue(perm.equals(perm2));
assertTrue(perm2.equals(perm));
perm.set(2, 1);
assertEquals(
"[3, 2, 1, 0]",
perm.toString());
assertFalse(perm.equals(perm2));
// clone not affected
assertEquals(
"[3, 2, 0, 1]",
perm2.toString());
perm2.set(2, 3);
assertEquals(
"[0, 2, 3, 1]",
perm2.toString());
}
@Test void testInsert() {
Permutation perm = new Permutation(new int[]{3, 0, 4, 2, 1});
perm.insertTarget(2);
assertEquals(
"[4, 0, 5, 3, 1, 2]",
perm.toString());
// insert at start
perm = new Permutation(new int[]{3, 0, 4, 2, 1});
perm.insertTarget(0);
assertEquals(
"[4, 1, 5, 3, 2, 0]",
perm.toString());
// insert at end
perm = new Permutation(new int[]{3, 0, 4, 2, 1});
perm.insertTarget(5);
assertEquals(
"[3, 0, 4, 2, 1, 5]",
perm.toString());
// insert into empty
perm = new Permutation(new int[]{});
perm.insertTarget(0);
assertEquals(
"[0]",
perm.toString());
}
@Test void testEmpty() {
final Permutation perm = new Permutation(0);
assertTrue(perm.isIdentity());
assertEquals(
"[]",
perm.toString());
assertTrue(perm.equals(perm));
assertTrue(perm.equals(perm.inverse()));
try {
perm.set(1, 0);
fail("expected exception");
} catch (ArrayIndexOutOfBoundsException e) {
// success
}
try {
perm.set(-1, 2);
fail("expected exception");
} catch (ArrayIndexOutOfBoundsException e) {
// success
}
}
@Test void testProjectPermutation() {
final RelDataTypeFactory typeFactory = new JavaTypeFactoryImpl();
final RexBuilder builder = new RexBuilder(typeFactory);
final RelDataType doubleType =
typeFactory.createSqlType(SqlTypeName.DOUBLE);
// A project with [1, 1] is not a permutation, so should return null
final Permutation perm = Project.getPermutation(2,
ImmutableList.of(builder.makeInputRef(doubleType, 1),
builder.makeInputRef(doubleType, 1)));
assertThat(perm, nullValue());
// A project with [0, 1, 0] is not a permutation, so should return null
final Permutation perm1 = Project.getPermutation(2,
ImmutableList.of(builder.makeInputRef(doubleType, 0),
builder.makeInputRef(doubleType, 1),
builder.makeInputRef(doubleType, 0)));
assertThat(perm1, nullValue());
// A project of [1, 0] is a valid permutation!
final Permutation perm2 = Project.getPermutation(2,
ImmutableList.of(builder.makeInputRef(doubleType, 1),
builder.makeInputRef(doubleType, 0)));
assertThat(perm2, is(new Permutation(new int[]{1, 0})));
}
}
|
3e0911891065908504659819cc5c4024b4b171f1 | 1,819 | java | Java | app/src/main/java/com/yong/job/three/SharedActivity.java | jyonger/Job | b21a55755e8aebc74bd8ef1784c7f803fb3724e7 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/yong/job/three/SharedActivity.java | jyonger/Job | b21a55755e8aebc74bd8ef1784c7f803fb3724e7 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/yong/job/three/SharedActivity.java | jyonger/Job | b21a55755e8aebc74bd8ef1784c7f803fb3724e7 | [
"Apache-2.0"
] | null | null | null | 32.482143 | 93 | 0.612974 | 3,841 | package com.yong.job.three;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.yong.job.R;
public class SharedActivity extends Activity {
private EditText write;
private Button btnWrite;
private TextView read;
private Button btnRead;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.three_shared_activity);
write = (EditText) findViewById(R.id.write);
btnWrite = (Button) findViewById(R.id.btn_write);
read = (TextView) findViewById(R.id.read);
btnRead = (Button) findViewById(R.id.btn_read);
btnWrite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences shared = getSharedPreferences("data-shared", MODE_PRIVATE);
SharedPreferences.Editor editor = shared.edit();
editor.putString("name", "tom");
editor.putInt("age", 11);
editor.putBoolean("sex", true);
editor.commit();
}
});
btnRead.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences shared = getSharedPreferences("data-shared", MODE_PRIVATE);
String data = "";
data = data + shared.getString("name", "jack");
data = data + shared.getInt("age", 0);
data = data + shared.getBoolean("sex", false);
read.setText(data);
}
});
}
}
|
3e0911dfa65ef7ff9e880cc021a0d72ad2f8aefc | 1,232 | java | Java | components/analytics-dashboard/org.wso2.carbon.analytics.dashboard.admin/src/main/java/org/wso2/carbon/analytics/dashboard/admin/data/Widget.java | kasungayan/CEP-Emailsender | 189c5f7aa613391ae89308309fe10ee3b58990e1 | [
"Apache-2.0"
] | null | null | null | components/analytics-dashboard/org.wso2.carbon.analytics.dashboard.admin/src/main/java/org/wso2/carbon/analytics/dashboard/admin/data/Widget.java | kasungayan/CEP-Emailsender | 189c5f7aa613391ae89308309fe10ee3b58990e1 | [
"Apache-2.0"
] | null | null | null | components/analytics-dashboard/org.wso2.carbon.analytics.dashboard.admin/src/main/java/org/wso2/carbon/analytics/dashboard/admin/data/Widget.java | kasungayan/CEP-Emailsender | 189c5f7aa613391ae89308309fe10ee3b58990e1 | [
"Apache-2.0"
] | null | null | null | 24.156863 | 82 | 0.699675 | 3,842 | /**
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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.wso2.carbon.analytics.dashboard.admin.data;
/**
* Holds information about a widget which is instantiated inside a DataView Object
*/
public class Widget {
private String id;
private String title;
private String config;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getConfig() {
return config;
}
public void setConfig(String config) {
this.config = config;
}
}
|
3e09124b2d8b0a614a8c8dabec705340df6b162e | 615 | java | Java | app/src/main/java/com/xuf/www/gobang/interator/NetInteractor.java | 1604653069/MyDesign2 | 52c586a63d01cf35311fd1da853de58ad5b0bf42 | [
"MIT"
] | 141 | 2016-02-25T06:48:12.000Z | 2021-11-08T11:09:26.000Z | app/src/main/java/com/xuf/www/gobang/interator/NetInteractor.java | 1604653069/MyDesign2 | 52c586a63d01cf35311fd1da853de58ad5b0bf42 | [
"MIT"
] | null | null | null | app/src/main/java/com/xuf/www/gobang/interator/NetInteractor.java | 1604653069/MyDesign2 | 52c586a63d01cf35311fd1da853de58ad5b0bf42 | [
"MIT"
] | 65 | 2016-03-04T17:07:06.000Z | 2021-12-24T10:02:52.000Z | 14.642857 | 85 | 0.663415 | 3,843 | package com.xuf.www.gobang.interator;
import android.bluetooth.BluetoothDevice;
import com.peak.salut.SalutDevice;
import com.xuf.www.gobang.bean.Message;
/**
* Created by lenov0 on 2016/2/21.
*/
public class NetInteractor {
public boolean init() {
return true;
}
public void unInit() {
}
public void startNetService() {
}
public void stopNetService() {
}
public void sendToDevice(Message message, boolean isHost) {
}
public void findPeers() {
}
public void connectToHost(SalutDevice salutHost, BluetoothDevice blueToothHost) {
}
}
|
3e0912d0dd885f0642a954abff10799cf7fabbc9 | 21,129 | java | Java | src/test/java/com/couchbase/jdbc/ProjectionJDBCDriverTests.java | joshwilliams/jdbc-cb | 65be5339552a53187584b1bc0b71dc67e4983265 | [
"Apache-2.0"
] | 17 | 2016-04-06T13:15:03.000Z | 2021-09-18T19:21:14.000Z | src/test/java/com/couchbase/jdbc/ProjectionJDBCDriverTests.java | joshwilliams/jdbc-cb | 65be5339552a53187584b1bc0b71dc67e4983265 | [
"Apache-2.0"
] | 62 | 2016-01-13T13:20:09.000Z | 2019-09-27T06:42:37.000Z | src/test/java/com/couchbase/jdbc/ProjectionJDBCDriverTests.java | joshwilliams/jdbc-cb | 65be5339552a53187584b1bc0b71dc67e4983265 | [
"Apache-2.0"
] | 14 | 2016-02-19T18:54:32.000Z | 2021-01-31T13:38:02.000Z | 35.39196 | 112 | 0.607554 | 3,844 | package com.couchbase.jdbc;
import com.couchbase.json.SQLJSON;
import com.couchbase.jdbc.CBResultSet;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.*;
import java.util.Map;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Types;
import java.util.HashMap;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@RunWith(JUnit4.class)
public class ProjectionJDBCDriverTests {
@BeforeClass
public static void init() throws Exception
{
TestUtil.resetEnvironmentProperties(null);
}
@SuppressWarnings("unchecked")
@Test
public void testSimpleData() throws Exception
{
JDBCTestUtils.setConnection(null);
JSONObject obj = new JSONObject();
JSONObject jsonObjNew = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("name", "test_name");
map.put("specialchars", "()*&^%$!@{}{}:\"\\\';::");
map.put("id", 12345);
map.put("double", 12345.333);
map.put("boolean", true);
map.put("data_time", "2001-01-01 01:01:01.00");
map.put("testid", "ProjectionJDBCDriverTests.testSimpleData");
obj.putAll(map);
JSONArray expectedArray = new JSONArray();
HashMap<String,JSONObject> objMap = new HashMap<String,JSONObject>();
objMap.put("1_testSimpleData", obj);
expectedArray.add(obj);
JDBCTestUtils.insertData(objMap, "default");
Thread.sleep(5000);
String query = "select * from default where testid = 'ProjectionJDBCDriverTests.testSimpleData'";
JDBCTestUtils.resetConnection();
try ( Connection con = JDBCTestUtils.con)
{
try (Statement stmt = con.createStatement())
{
try (ResultSet rs = stmt.executeQuery(query))
{
while(rs.next()){
CBResultSet cbrs = (CBResultSet) rs;
java.sql.ResultSetMetaData meta = cbrs.getMetaData();
SQLJSON jsonVal1 = cbrs.getSQLJSON("default");
Map actualMap = jsonVal1.getMap();
if(actualMap != null){
jsonObjNew.putAll(actualMap);
}
assertEquals(obj, jsonObjNew);
}
}
finally{
stmt.executeUpdate("delete from default");
Thread.sleep(10000);
}
}
}
}
@SuppressWarnings("unchecked")
@Test
public void testNulls() throws Exception
{
JDBCTestUtils.setConnection(null);
JDBCTestUtils.deleteDataFromBucket("default");
JSONObject obj = new JSONObject();
JSONObject jsonObjNew = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("name", null);
obj.putAll(map);
JSONArray expectedArray = new JSONArray();
HashMap<String,JSONObject> objMap = new HashMap<String,JSONObject>();
objMap.put("1_testNulls", obj);
expectedArray.add(obj);
JDBCTestUtils.insertData(objMap, "default");
Thread.sleep(5000);
String query = "select * from default";
JDBCTestUtils.resetConnection();
try ( Connection con = JDBCTestUtils.con)
{
try (Statement stmt = con.createStatement())
{
try (ResultSet rs = stmt.executeQuery(query))
{
while(rs.next()){
CBResultSet cbrs = (CBResultSet) rs;
java.sql.ResultSetMetaData meta = cbrs.getMetaData();
SQLJSON jsonVal1 = cbrs.getSQLJSON("default");
Map actualMap = jsonVal1.getMap();
if(actualMap != null){
jsonObjNew.putAll(actualMap);
}
assertEquals(obj, jsonObjNew);
}
}
finally{
stmt.executeUpdate("delete from default");
Thread.sleep(10000);
}
}
}
}
@SuppressWarnings("unchecked")
@Test
public void testSimpleDataWithNull() throws Exception
{
JDBCTestUtils.setConnection(null);
JDBCTestUtils.deleteDataFromBucket("default");
JSONObject obj = new JSONObject();
JSONObject jsonObjNew = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("name", null);
obj.putAll(map);
JSONArray expectedArray = new JSONArray();
HashMap<String,JSONObject> objMap = new HashMap<String,JSONObject>();
objMap.put("1_testSimpleDataWithNull", obj);
expectedArray.add(obj);
JDBCTestUtils.insertData(objMap, "default");
Thread.sleep(5000);
String query = "select * from default";
JDBCTestUtils.resetConnection();
try ( Connection con = JDBCTestUtils.con)
{
try (Statement stmt = con.createStatement())
{
try (ResultSet rs = stmt.executeQuery(query))
{
while(rs.next()){
CBResultSet cbrs = (CBResultSet) rs;
java.sql.ResultSetMetaData meta = cbrs.getMetaData();
SQLJSON jsonVal1 = cbrs.getSQLJSON("default");
Map actualMap = jsonVal1.getMap();
if(actualMap != null){
jsonObjNew.putAll(actualMap);
}
assertEquals(obj, jsonObjNew);
}
}
finally{
stmt.executeUpdate("delete from default");
Thread.sleep(10000);
}
}
}
}
@SuppressWarnings({ "unchecked", "deprecation", "resource" })
@Test
public void testSimpleDataDifferentDataTypesAsFields() throws Exception
{
JDBCTestUtils.setConnection(null);
JSONObject obj = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("name", "test_name");
map.put("specialchars", "()*&^%$!@{}{}:\"\\\';::");
map.put("int", 12345);
map.put("double", 12345.333);
map.put("data_time", "2001-01-01 01:01:01.00");
obj.putAll(map);
JSONArray expectedArray = new JSONArray();
HashMap<String,JSONObject> objMap = new HashMap<String,JSONObject>();
objMap.put("1_testSimpleDataDifferentDataTypesAsFields", obj);
expectedArray.add(obj);
JDBCTestUtils.insertData(objMap, "default");
Thread.sleep(20000);
String query = "select name,specialchars,int,double,data_time from default";
JDBCTestUtils.setConnection(null);
try ( Connection con = JDBCTestUtils.con)
{
try (Statement stmt = con.createStatement())
{
try (ResultSet rs = stmt.executeQuery(query))
{
while(rs.next()){
CBResultSet cbrs = (CBResultSet) rs;
java.sql.ResultSetMetaData meta = cbrs.getMetaData();
SQLJSON jsonVal1 = cbrs.getSQLJSON("name");
assertEquals(12, jsonVal1.getJDBCType());
assertEquals("test_name", jsonVal1.getString());
jsonVal1 = cbrs.getSQLJSON("specialchars");
assertEquals(12, jsonVal1.getJDBCType());
assertEquals("()*&^%$!@{}{}:\"\\\';::", jsonVal1.getString());
jsonVal1 = cbrs.getSQLJSON("int");
assertEquals(2, jsonVal1.getJDBCType());
assertEquals(12345, jsonVal1.getInt());
jsonVal1 = cbrs.getSQLJSON("double");
assertEquals(2, jsonVal1.getJDBCType());
//assertEquals(12345.333, jsonVal1.getDouble());
}
}
finally{
stmt.executeUpdate("delete from default");
Thread.sleep(10000);
}
}
}
}
@SuppressWarnings("unchecked")
@Test
public void testNestedOperator() throws Exception
{
JDBCTestUtils.setConnection(null);
JSONObject obj = new JSONObject();
JSONObject nestedobj = new JSONObject();
JSONObject jsonObjNew = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
nestedobj.put("nested.nested", "1");
map.put("name", "test_name");
map.put("specialchars", "()*&^%$!@{}{}:\"\\\';::");
map.put("id", 12345);
map.put("double", 12345.333);
map.put("data_time", "2001-01-01 01:01:01.00");
obj.put("nested", nestedobj);
obj.putAll(map);
JSONArray expectedArray = new JSONArray();
HashMap<String,JSONObject> objMap = new HashMap<String,JSONObject>();
objMap.put("1_testNestedOperator", obj);
expectedArray.add(nestedobj);
JDBCTestUtils.insertData(objMap, "default");
Thread.sleep(10000);
String query = "select default.nested.* from default";
JDBCTestUtils.resetConnection();
try ( Connection con = JDBCTestUtils.con)
{
try (Statement stmt = con.createStatement())
{
try (ResultSet rs = stmt.executeQuery(query))
{
while(rs.next()){
assertEquals("1", rs.getString("nested.nested"));
}
}
finally{
stmt.executeUpdate("delete from default");
Thread.sleep(10000);
}
}
}
}
@SuppressWarnings("unchecked")
@Test
public void testNoResult() throws Exception
{
JDBCTestUtils.setConnection(null);
JSONObject obj = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("name", "test_name");
obj.putAll(map);
JSONArray expectedArray = new JSONArray();
HashMap<String,JSONObject> objMap = new HashMap<String,JSONObject>();
objMap.put("2_testNestedOperator", obj);
JDBCTestUtils.insertData(objMap, "default");
Thread.sleep(10000);
String query = "select * from default where x=1234";
JSONArray actualArray = JDBCTestUtils.runQueryAndExtractMap(query);
assertEquals(expectedArray, actualArray);
// Clean up after ourselves.
JDBCTestUtils.setConnection(null);
Statement stmt = JDBCTestUtils.con.createStatement();
stmt.executeUpdate("delete from default");
Thread.sleep(10000);
}
@SuppressWarnings("unchecked")
@Test
public void testNoResultWithBucketEmpty() throws Exception
{
JDBCTestUtils.setConnection(null);
JSONArray expectedArray = new JSONArray();
String query = "select * from default where x=1234";
JSONArray actualArray = JDBCTestUtils.runQueryAndExtractMap(query);
assertEquals(expectedArray, actualArray);
}
@SuppressWarnings("unchecked")
//@Test
public void testQueryAggregate() throws Exception
{
JDBCTestUtils.setConnection(null);
JSONObject obj = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("name", "test_name");
map.put("specialchars", "()*&^%$!@{}{}:\"\\\';::");
map.put("id", 12345);
map.put("double", 12345.333);
map.put("data_time", "2001-01-01 01:01:01.00");
obj.putAll(map);
JSONArray expectedArray = new JSONArray();
HashMap<String,JSONObject> objMap = new HashMap<String,JSONObject>();
objMap.put("1_testQueryAggregate", obj);
JSONObject expectedObject = new JSONObject();
expectedObject.put("$1", "1");
expectedArray.add(expectedObject);
JDBCTestUtils.insertData(objMap, "default");
String query = "select count(*) from default";
JSONArray actualArray = JDBCTestUtils.runQueryAndExtractMap(query);
assertEquals(expectedArray, actualArray);
}
@SuppressWarnings("unchecked")
@Test
public void testQueryAggregateWithAlias() throws Exception
{
JDBCTestUtils.setConnection(null);
JSONObject obj = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("name", "test_name");
map.put("specialchars", "()*&^%$!@{}{}:\"\\\';::");
map.put("id", 12345);
map.put("double", 12345.333);
map.put("data_time", "2001-01-01 01:01:01.00");
obj.putAll(map);
JSONArray expectedArray = new JSONArray();
HashMap<String,JSONObject> objMap = new HashMap<String,JSONObject>();
objMap.put("1_testQueryAggregateWithAlias", obj);
JSONObject expectedObject = new JSONObject();
expectedObject.put("name", "test_value");
expectedArray.add(expectedObject);
JDBCTestUtils.insertData(objMap, "default");
Thread.sleep(5000);
String query = "select count(*) as alias_count from default";
JDBCTestUtils.resetConnection();
try ( Connection con = JDBCTestUtils.con)
{
try (Statement stmt = con.createStatement())
{
try (ResultSet rs = stmt.executeQuery(query))
{
while(rs.next()){
CBResultSet cbrs = (CBResultSet) rs;
java.sql.ResultSetMetaData meta = cbrs.getMetaData();
SQLJSON jsonVal1 = cbrs.getSQLJSON("alias_count");
int actual = jsonVal1.getInt();
assertEquals(1, actual);
}
}
finally{
stmt.executeUpdate("delete from default");
Thread.sleep(10000);
}
}
}
}
@SuppressWarnings("unchecked")
@Test
public void testNestedSelectAllData() throws Exception
{
JDBCTestUtils.setConnection(null);
JSONObject obj = new JSONObject();
JSONObject jsonObjNew = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
JSONObject nestedObject = new JSONObject();
obj.put("nested_data", nestedObject);
obj.putAll(map);
HashMap<String,JSONObject> objMap = new HashMap<String,JSONObject>();
objMap.put("1_testNestedSelectAllData", obj);
JDBCTestUtils.insertData(objMap, "default");
Thread.sleep(15000);
String query = "select default.* from default";
JDBCTestUtils.resetConnection();
try ( Connection con = JDBCTestUtils.con)
{
try (Statement stmt = con.createStatement())
{
try (ResultSet rs = stmt.executeQuery(query))
{
while(rs.next()){
assertEquals("{}", rs.getString("nested_data"));
}
}
finally{
stmt.executeUpdate("delete from default");
Thread.sleep(10000);
}
}
}
}
@SuppressWarnings({ "unchecked", "resource" })
@Test
public void testSeriesOfObjectsWithSimilarFields() throws Exception
{
JDBCTestUtils.setConnection(null);
JSONObject obj = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("name", "test_name");
map.put("id", 12345);
JSONObject nestedObject1 = new JSONObject();
JSONObject nestedObject2 = new JSONObject();
nestedObject1.put("nest_field_name_1", "test_nest_1");
nestedObject1.put("nest_field_id_1", 1);
nestedObject2.put("nest_field_name_2", "test_nest_2");
nestedObject2.put("nest_field_id_2", 2);
JSONArray expectedArray = new JSONArray();
obj.put("nested_data_1", nestedObject1);
obj.put("nested_data_2", nestedObject2);
obj.putAll(map);
HashMap<String,JSONObject> objMap = new HashMap<String,JSONObject>();
objMap.put("1_testSeriesOfObjectsWithSimilarFields", obj);
JSONObject expectedJSONObject = new JSONObject();
expectedJSONObject.put("nested_data_1", nestedObject1);
expectedJSONObject.put("nested_data_2", nestedObject2);
expectedArray.add(expectedJSONObject);
JDBCTestUtils.insertData(objMap, "default");
Thread.sleep(20000);
String query = "select default.nested_data_2.* , default.nested_data_1.* from default";
JDBCTestUtils.setConnection(null);
try ( Connection con = JDBCTestUtils.con)
{
try (Statement stmt = con.createStatement())
{
try (ResultSet rs = stmt.executeQuery(query))
{
while(rs.next()){
assertEquals(1, rs.getInt("nest_field_id_1"));
assertEquals("2", rs.getString("nest_field_id_2"));
assertEquals("test_nest_1", rs.getString("nest_field_name_1"));
assertEquals("test_nest_2", rs.getString("nest_field_name_2"));
}
}
finally{
stmt.executeUpdate("delete from default");
Thread.sleep(10000);
}
}
}
}
@SuppressWarnings("unchecked")
@Test
public void testArrayAndNestedSelectAllData() throws Exception
{
JDBCTestUtils.setConnection(null);
JSONObject obj = new JSONObject();
JSONObject jsonObjNew = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
JSONObject nestedObject = new JSONObject();
JSONArray jsonarrayForNesting = new JSONArray();
for(int i=0;i<100;++i){
jsonarrayForNesting.add(i);
}
nestedObject.put("nested_array", jsonarrayForNesting);
JSONArray expectedArray = new JSONArray();
obj.put("nested_data", nestedObject);
obj.putAll(map);
HashMap<String,JSONObject> objMap = new HashMap<String,JSONObject>();
objMap.put("1_testArrayAndNestedSelectAllData", obj);
expectedArray.add(obj);
JDBCTestUtils.insertData(objMap, "default");
Thread.sleep(30000);
String query = "select nested_data.* from default";
JDBCTestUtils.resetConnection();
try ( Connection con = JDBCTestUtils.con)
{
try (Statement stmt = con.createStatement())
{
try (ResultSet rs = stmt.executeQuery(query))
{
while(rs.next()){
CBResultSet cbrs = (CBResultSet) rs;
java.sql.ResultSetMetaData meta = cbrs.getMetaData();
SQLJSON jsonVal1 = cbrs.getSQLJSON("nested_array");
Object obj1 = jsonVal1.getObject();
assertEquals(jsonarrayForNesting.toString().replace(" ",""), obj1.toString().replace(" ",""));
}
}
finally{
stmt.executeUpdate("delete from default");
Thread.sleep(10000);
}
}
}
}
@SuppressWarnings("unchecked")
@Test
public void testFieldAlias() throws Exception
{
JDBCTestUtils.setConnection(null);
JSONObject obj = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("name", "test_name");
map.put("id", 12345);
map.put("double", 12345.333);
map.put("data_time", "2001-01-01 01:01:01.00");
obj.putAll(map);
JSONArray expectedArray = new JSONArray();
HashMap<String,JSONObject> objMap = new HashMap<String,JSONObject>();
objMap.put("1_testFieldAlias", obj);
JSONObject jObject = new JSONObject();
jObject.put("alias_name", "test_name");
jObject.put("alias_id", 12345);
expectedArray.add(jObject);
JDBCTestUtils.insertData(objMap, "default");
Thread.sleep(5000);
String query = "select name as alias_name, id as alias_id from default";
JDBCTestUtils.resetConnection();
try ( Connection con = JDBCTestUtils.con)
{
try (Statement stmt = con.createStatement())
{
try (ResultSet rs = stmt.executeQuery(query))
{
while(rs.next()){
CBResultSet cbrs = (CBResultSet) rs;
java.sql.ResultSetMetaData meta = cbrs.getMetaData();
SQLJSON jsonVal1 = cbrs.getSQLJSON("alias_name");
String actualString = jsonVal1.getString();
assertEquals("test_name", actualString);
}
}
finally{
stmt.executeUpdate("delete from default");
Thread.sleep(10000);
}
}
}
}
@SuppressWarnings("unchecked")
@Test
public void testOneFieldCall() throws Exception
{
JDBCTestUtils.setConnection(null);
JSONObject obj = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("name", "test_name");
obj.putAll(map);
HashMap<String,JSONObject> objMap = new HashMap<String,JSONObject>();
objMap.put("1_unchecked", obj);
Thread.sleep(2000);
JDBCTestUtils.insertData(objMap, "default");
String query = "select name from default";
JDBCTestUtils.resetConnection();
try ( Connection con = JDBCTestUtils.con)
{
try (Statement stmt = con.createStatement())
{
try (ResultSet rs = stmt.executeQuery(query))
{
while(rs.next()){
CBResultSet cbrs = (CBResultSet) rs;
java.sql.ResultSetMetaData meta = cbrs.getMetaData();
SQLJSON jsonVal1 = cbrs.getSQLJSON("name");
String actualString = jsonVal1.getString();
assertEquals("test_name", actualString);
}
}
finally{
stmt.executeUpdate("delete from default");
Thread.sleep(10000);
}
}
}
}
}
|
3e0913076ca238a6ca23ac12e228e70bf34da806 | 8,147 | java | Java | java/service-connector/sc-lib/src/main/java/org/serviceconnector/web/xml/LogsXMLLoader.java | mzukal/test | 7440d2ab95cc626f0e5e7b2207d73e6bcd8c6e01 | [
"Apache-2.0"
] | 1 | 2020-05-13T10:48:41.000Z | 2020-05-13T10:48:41.000Z | java/service-connector/sc-lib/src/main/java/org/serviceconnector/web/xml/LogsXMLLoader.java | mzukal/test | 7440d2ab95cc626f0e5e7b2207d73e6bcd8c6e01 | [
"Apache-2.0"
] | 2 | 2020-05-13T11:08:10.000Z | 2020-05-13T15:00:05.000Z | java/service-connector/sc-lib/src/main/java/org/serviceconnector/web/xml/LogsXMLLoader.java | mzukal/test | 7440d2ab95cc626f0e5e7b2207d73e6bcd8c6e01 | [
"Apache-2.0"
] | 1 | 2020-05-29T14:45:02.000Z | 2020-05-29T14:45:02.000Z | 37.543779 | 141 | 0.655333 | 3,845 | /*-----------------------------------------------------------------------------*
* *
* Copyright © 2010 STABILIT Informatik AG, Switzerland *
* *
* 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.serviceconnector.web.xml;
import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import org.serviceconnector.web.IWebRequest;
import org.serviceconnector.web.WebUtil;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.FileAppender;
/**
* The Class LogXMLLoader.
*/
public class LogsXMLLoader extends AbstractXMLLoader {
/** The distinct logger set, prevent multiple entries of log files. */
private Set<String> distinctLoggerSet;
/**
* Instantiates a new default xml loader.
*/
public LogsXMLLoader() {
distinctLoggerSet = new HashSet<String>();
}
/**
* Load body.
*
* @param writer the writer
* @param request the request
* @throws Exception the exception {@inheritDoc}
*/
@Override
public final void loadBody(XMLStreamWriter writer, IWebRequest request) throws Exception {
writer.writeStartElement("logs");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date today = cal.getTime();
Date current = this.writeXMLDate(writer, request);
if (today.before(current)) {
current = today;
}
// write available log levels
writeLogLevels(writer);
ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
writeLogger(writer, rootLogger, today, current);
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
List<ch.qos.logback.classic.Logger> currentLoggers = loggerContext.getLoggerList();
for (ch.qos.logback.classic.Logger currentLogger : currentLoggers) {
Iterator<Appender<ILoggingEvent>> appenders = currentLogger.iteratorForAppenders();
if (appenders.hasNext()) {
writeLogger(writer, currentLogger, today, current);
}
}
writer.writeEndElement(); // close logs tag
}
private void writeLogLevels(XMLStreamWriter writer) throws Exception {
writer.writeStartElement("log-levels");
writer.writeStartElement("level");
writer.writeCharacters(Level.ALL.toString());
writer.writeEndElement();
writer.writeStartElement("level");
writer.writeCharacters(Level.DEBUG.toString());
writer.writeEndElement();
writer.writeStartElement("level");
writer.writeCharacters(Level.ERROR.toString());
writer.writeEndElement();
// writer.writeStartElement("level");
// writer.writeCharacters(Level.FATAL.toString());
// writer.writeEndElement();
writer.writeStartElement("level");
writer.writeCharacters(Level.INFO.toString());
writer.writeEndElement();
writer.writeStartElement("level");
writer.writeCharacters(Level.OFF.toString());
writer.writeEndElement();
writer.writeStartElement("level");
writer.writeCharacters(Level.TRACE.toString());
writer.writeEndElement();
writer.writeStartElement("level");
writer.writeCharacters(Level.WARN.toString());
writer.writeEndElement();
writer.writeEndElement(); // end of log-levels
}
/**
* Write logger.
*
* @param writer the writer
* @param logger the logger
* @param today the today
* @param current the current
* @throws XMLStreamException the xML stream exception
*/
public void writeLogger(XMLStreamWriter writer, ch.qos.logback.classic.Logger logger, Date today, Date current) throws XMLStreamException {
writer.writeStartElement("logger");
writer.writeAttribute("name", logger.getName());
Iterator<Appender<ILoggingEvent>> appenders = logger.iteratorForAppenders();
Level level = logger.getLevel();
writer.writeStartElement("level");
writer.writeCharacters(level.toString());
writer.writeEndElement();
while (appenders.hasNext()) {
Appender appender = appenders.next();
String appenderName = appender.getName();
if (distinctLoggerSet.contains(appenderName)) {
continue;
}
distinctLoggerSet.add(appenderName);
writer.writeStartElement("appender");
writer.writeAttribute("name", appender.getName());
if (appender instanceof FileAppender) {
writer.writeAttribute("type", "file");
FileAppender fileAppender = (FileAppender) appender;
String sFile = fileAppender.getFile();
if (current.before(today)) {
sFile += "." + WebUtil.getXMLDateAsString(current);
}
writer.writeStartElement("file");
File file = new File(sFile);
if (file.exists() && file.isFile()) {
long length = file.length();
writer.writeAttribute("size", String.valueOf(length));
writer.writeCData(sFile);
}
writer.writeEndElement();
}
writer.writeEndElement(); // close appender tag
}
writer.writeEndElement(); // close logger tag
}
/**
* Gets the current log files.
*
* @return the current log files
*/
protected List<String> getCurrentLogFiles() {
distinctLoggerSet.clear();
List<String> logFileList = new ArrayList<String>();
ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
addLogFiles(rootLogger, logFileList);
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
List<ch.qos.logback.classic.Logger> currentLoggers = loggerContext.getLoggerList();
for (ch.qos.logback.classic.Logger currentLogger : currentLoggers) {
Iterator<Appender<ILoggingEvent>> appenders = currentLogger.iteratorForAppenders();
if (appenders.hasNext()) {
addLogFiles(currentLogger, logFileList);
}
}
return logFileList;
}
/**
* Adds the log files.
*
* @param logger the logger
* @param logFileList the log file list
*/
protected void addLogFiles(ch.qos.logback.classic.Logger logger, List<String> logFileList) {
Iterator<Appender<ILoggingEvent>> appenders = logger.iteratorForAppenders();
while (appenders.hasNext()) {
Appender appender = appenders.next();
String appenderName = appender.getName();
if (distinctLoggerSet.contains(appenderName)) {
continue;
}
distinctLoggerSet.add(appenderName);
if (appender instanceof FileAppender) {
FileAppender fileAppender = (FileAppender) appender;
String sFile = fileAppender.getFile();
File file = new File(sFile);
if (file.exists() && file.isFile()) {
logFileList.add(sFile);
}
}
}
}
}
|
3e09133c435a861e524a9f814c0409171ea34460 | 1,929 | java | Java | x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/LockableLifecycleType.java | YMhao/elasticsearch | 3bb826aa5cf477d3f0cc2397bda517d501c08b9a | [
"Apache-2.0"
] | 3 | 2017-05-31T14:46:18.000Z | 2022-02-15T08:04:05.000Z | x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/LockableLifecycleType.java | YMhao/elasticsearch | 3bb826aa5cf477d3f0cc2397bda517d501c08b9a | [
"Apache-2.0"
] | 61 | 2015-01-09T10:44:57.000Z | 2018-04-17T14:56:08.000Z | x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/LockableLifecycleType.java | YMhao/elasticsearch | 3bb826aa5cf477d3f0cc2397bda517d501c08b9a | [
"Apache-2.0"
] | 4 | 2015-02-02T03:10:59.000Z | 2017-02-18T19:26:04.000Z | 29.676923 | 92 | 0.731985 | 3,846 | /*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.indexlifecycle;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleAction;
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleType;
import org.elasticsearch.xpack.core.indexlifecycle.Phase;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* This {@link LifecycleType} is used for encapsulating test policies
* used in integration tests where the underlying {@link LifecycleAction}s are
* able to communicate with the test
*/
public class LockableLifecycleType implements LifecycleType {
public static final String TYPE = "lockable";
public static final LockableLifecycleType INSTANCE = new LockableLifecycleType();
@Override
public List<Phase> getOrderedPhases(Map<String, Phase> phases) {
return new ArrayList<>(phases.values());
}
@Override
public String getNextPhaseName(String currentPhaseName, Map<String, Phase> phases) {
return null;
}
@Override
public String getPreviousPhaseName(String currentPhaseName, Map<String, Phase> phases) {
return null;
}
@Override
public List<LifecycleAction> getOrderedActions(Phase phase) {
return new ArrayList<>(phase.getActions().values());
}
@Override
public String getNextActionName(String currentActionName, Phase phase) {
return null;
}
@Override
public void validate(Collection<Phase> phases) {
}
@Override
public String getWriteableName() {
return TYPE;
}
@Override
public void writeTo(StreamOutput out) {
}
}
|
3e091392dcafde5ec92eaa9696c83f675a22253a | 13,655 | java | Java | currency-plugin/src/main/java/cn/hamster3/currency/core/SQLDataManager.java | MiniDay/HamsterCurrency-Parent | 616eee7b6aebbe31187ca08f5cf98749fe697e53 | [
"MIT"
] | null | null | null | currency-plugin/src/main/java/cn/hamster3/currency/core/SQLDataManager.java | MiniDay/HamsterCurrency-Parent | 616eee7b6aebbe31187ca08f5cf98749fe697e53 | [
"MIT"
] | null | null | null | currency-plugin/src/main/java/cn/hamster3/currency/core/SQLDataManager.java | MiniDay/HamsterCurrency-Parent | 616eee7b6aebbe31187ca08f5cf98749fe697e53 | [
"MIT"
] | null | null | null | 39.694767 | 144 | 0.554302 | 3,847 | package cn.hamster3.currency.core;
import cn.hamster3.currency.HamsterCurrency;
import cn.hamster3.currency.data.CurrencyType;
import cn.hamster3.currency.data.PlayerData;
import cn.hamster3.service.bukkit.api.ServiceMessageAPI;
import com.google.gson.JsonParser;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
import static cn.hamster3.currency.HamsterCurrency.getLogUtils;
public class SQLDataManager implements IDataManager {
private final HamsterCurrency plugin;
private final JsonParser parser;
private final String database;
private final HikariDataSource dataSource;
private final HashSet<PlayerData> playerData;
private final HashSet<CurrencyType> currencyTypes;
public SQLDataManager(HamsterCurrency plugin) throws SQLException, ClassNotFoundException {
this.plugin = plugin;
parser = new JsonParser();
playerData = new HashSet<>();
currencyTypes = new HashSet<>();
ConfigurationSection datasourceConfig = FileManager.getPluginConfig().getConfigurationSection("datasource");
database = datasourceConfig.getString("database");
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setDriverClassName(datasourceConfig.getString("driver"));
hikariConfig.setJdbcUrl(datasourceConfig.getString("url"));
hikariConfig.setUsername(datasourceConfig.getString("user"));
hikariConfig.setPassword(datasourceConfig.getString("password"));
hikariConfig.setMaximumPoolSize(10);
hikariConfig.setMinimumIdle(1);
dataSource = new HikariDataSource(hikariConfig);
Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
statement.execute("CREATE TABLE IF NOT EXISTS " + database + ".hamster_currency_player_data(" +
"uuid VARCHAR(36) PRIMARY KEY," +
"data TEXT" +
") CHARACTER SET = utf8mb4;");
statement.execute("CREATE TABLE IF NOT EXISTS " + database + ".hamster_currency_settings(" +
"title VARCHAR(64) PRIMARY KEY," +
"data TEXT" +
") CHARACTER SET = utf8mb4;");
statement.close();
connection.close();
}
public void uploadConfigToSQL() {
getLogUtils().info("重载配置文件...");
FileManager.reload(plugin);
FileConfiguration config = FileManager.getPluginConfig();
getLogUtils().info("配置文件重载完成!");
try {
getLogUtils().info("将配置文件上传至数据库...");
Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
String data = Base64.getEncoder().encodeToString(config.saveToString().getBytes(StandardCharsets.UTF_8));
statement.executeUpdate(String.format(
"REPLACE INTO " + database + ".hamster_currency_settings VALUES('%s', '%s');",
"pluginConfig",
data
));
statement.close();
connection.close();
getLogUtils().info("配置文件上传完成!");
} catch (SQLException e) {
getLogUtils().error(e, "插件上传 pluginConfig 至数据库时遇到了一个异常: ");
}
loadConfig(config);
ServiceMessageAPI.sendServiceMessage("HamsterCurrency", "uploadConfigToSQL");
}
@SuppressWarnings("SwitchStatementWithTooFewBranches")
public void loadConfigFromSQL() {
try {
getLogUtils().info("从数据库中下载配置文件...");
Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
ResultSet set = statement.executeQuery("SELECT * FROM " + database + ".hamster_currency_settings;");
while (set.next()) {
String title = set.getString("title");
String data = new String(Base64.getDecoder().decode(set.getString("data")), StandardCharsets.UTF_8);
switch (title) {
case "pluginConfig": {
YamlConfiguration config = new YamlConfiguration();
try {
config.loadFromString(data);
} catch (InvalidConfigurationException e) {
getLogUtils().error(e, "插件加载 %s 时遇到了一个异常: ", title);
}
loadConfig(config);
}
}
}
statement.close();
connection.close();
getLogUtils().info("配置文件下载完成!");
} catch (SQLException e) {
getLogUtils().error(e, "插件从数据库中下载 pluginConfig 时遇到了一个异常: ");
}
}
private void loadConfig(FileConfiguration config) {
getLogUtils().info("加载配置文件...");
currencyTypes.clear();
ConfigurationSection currencyTypesConfig = config.getConfigurationSection("currencyTypes");
for (String key : currencyTypesConfig.getKeys(false)) {
try {
currencyTypes.add(new CurrencyType(currencyTypesConfig.getConfigurationSection(key)));
getLogUtils().warning("已加载货币类型: %s", key);
} catch (Exception e) {
getLogUtils().error(e, "加载货币类型 %s 时出现了一个错误: ", key);
}
}
FileManager.setPluginConfig(config);
getLogUtils().info("配置文件加载完成!");
}
public void importFromOtherPluginData(String database, String table, String uuidCol, String nameCol, String moneyCol, String currencyType) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
getLogUtils().info("开始从其他插件的数据库存档中导入数据: ");
getLogUtils().info("数据库名: %s", database);
getLogUtils().info("数据表名: %s", table);
getLogUtils().info("玩家uuid列名: %s", uuidCol);
getLogUtils().info("玩家名称列名: %s", nameCol);
getLogUtils().info("玩家经济列名: %s", moneyCol);
getLogUtils().info("导入至经济类型: %s", currencyType);
try {
Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
ResultSet set = statement.executeQuery(String.format("SELECT * FROM %s.%s;", database, table));
synchronized (playerData) {
while (set.next()) {
try {
UUID uuid = UUID.fromString(set.getString(uuidCol));
String name = set.getString(nameCol);
double money = set.getDouble(moneyCol);
PlayerData data = getPlayerData(uuid);
if (data == null) {
data = new PlayerData(uuid, name);
playerData.add(data);
}
data.setPlayerCurrency(currencyType, money);
getLogUtils().info("已从其他插件中加载了玩家 %s 的存档数据.", data.getUuid());
} catch (Exception e) {
getLogUtils().error(e, "导入某一条数据时发生了一个错误: ");
}
}
}
for (PlayerData data : playerData) {
statement.executeUpdate(String.format(
"REPLACE INTO " + database + ".hamster_currency_player_data VALUES('%s', '%s');",
data.getUuid().toString(),
data.saveToJson().toString()
));
getLogUtils().info("已保存玩家 %s 的存档数据.", data.getUuid());
ServiceMessageAPI.sendServiceMessage("HamsterCurrency", "savedPlayerData", data.getUuid().toString());
}
statement.close();
connection.close();
} catch (SQLException e) {
getLogUtils().error(e, "从其他插件中导入数据时发生了一个异常:");
}
});
}
@Override
public void onEnable() {
getLogUtils().info("从数据库中读取玩家数据...");
try {
Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
ResultSet set = statement.executeQuery("SELECT * FROM " + database + ".hamster_currency_player_data;");
synchronized (playerData) {
while (set.next()) {
String uuid = set.getString("uuid");
String string = set.getString("data");
try {
PlayerData data = new PlayerData(parser.parse(string).getAsJsonObject());
playerData.add(data);
} catch (Exception e) {
getLogUtils().error(e, "从数据库中读取玩家 %s 的存档( %s )时出现了一个异常: ", uuid, string);
}
}
}
set.close();
statement.close();
connection.close();
} catch (SQLException e) {
getLogUtils().error(e, "从数据库中读取玩家数据时出现了一个异常:");
}
getLogUtils().info("从数据库中读取玩家数据完成!");
}
@Override
public void onDisable() {
// 因为SQL模式使用HamsterService前置
// 服务器之间数据实时同步
// 所以关服时无需保存任何数据
}
@Override
public void loadConfig() {
if (FileManager.isMainServer()) {
uploadConfigToSQL();
} else {
loadConfigFromSQL();
}
}
@Override
public void reloadConfig() {
ServiceMessageAPI.sendServiceMessage("HamsterCurrency", "reload");
}
@Override
public void loadPlayerData(UUID uuid) {
try {
Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
ResultSet set = statement.executeQuery(String.format(
"SELECT * FROM " + database + ".hamster_currency_player_data WHERE uuid='%s';",
uuid
));
PlayerData data;
if (set.next()) {
String string = set.getString("data");
try {
data = new PlayerData(parser.parse(string).getAsJsonObject());
} catch (Exception e) {
getLogUtils().error(e, "从数据库中读取玩家 %s 的存档( %s )时出现了一个异常: ", uuid, string);
statement.close();
return;
}
} else {
data = new PlayerData(uuid);
getLogUtils().info("初始化玩家 %s 的存档数据.", data.getUuid());
}
synchronized (playerData) {
playerData.remove(data);
playerData.add(data);
}
set.close();
statement.close();
connection.close();
getLogUtils().info("已加载玩家 %s 的存档数据.", data.getUuid());
} catch (SQLException e) {
getLogUtils().error(e, "加载玩家 %s 的存档数据时出错!", uuid);
}
}
@Override
public void savePlayerData(PlayerData data) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
statement.executeUpdate(String.format(
"REPLACE INTO " + database + ".hamster_currency_player_data VALUES('%s', '%s');",
data.getUuid().toString(),
data.saveToJson().toString()
));
statement.close();
connection.close();
} catch (SQLException e) {
getLogUtils().error(e, "保存玩家 %s 的存档数据时出错!", data.getUuid());
}
getLogUtils().info("已保存玩家 %s 的存档数据.", data.getUuid());
ServiceMessageAPI.sendServiceMessage(
"HamsterCurrency",
"savedPlayerData",
data.getUuid().toString()
);
});
}
@Override
public PlayerData getPlayerData(UUID uuid) {
synchronized (playerData) {
for (PlayerData data : playerData) {
if (uuid.equals(data.getUuid())) {
return data;
}
}
}
return null;
}
@Override
public PlayerData getPlayerData(String name) {
synchronized (playerData) {
for (PlayerData data : playerData) {
if (name.equalsIgnoreCase(data.getPlayerName())) {
return data;
}
}
}
return null;
}
@Override
public ArrayList<PlayerData> getPlayerData() {
synchronized (playerData) {
return new ArrayList<>(playerData);
}
}
@Override
public CurrencyType getCurrencyType(String id) {
for (CurrencyType type : currencyTypes) {
if (type.getId().equalsIgnoreCase(id)) {
return type;
}
}
return null;
}
@Override
public Set<CurrencyType> getCurrencyTypes() {
return currencyTypes;
}
}
|
3e0913d274129dcd371027d482d781d9c4da5d29 | 2,849 | java | Java | jadx/src/main/java/jadx/core/dex/visitors/MethodInlineVisitor.java | gzu-liyujiang/aa_reverse | f938da545fd93ef9bac9b32f2af88fe9d3916d7d | [
"Apache-2.0"
] | 12 | 2020-02-13T03:39:22.000Z | 2021-12-05T14:23:31.000Z | jadx/src/main/java/jadx/core/dex/visitors/MethodInlineVisitor.java | githubXiaowangzi/aa_reverse | f938da545fd93ef9bac9b32f2af88fe9d3916d7d | [
"Apache-2.0"
] | null | null | null | jadx/src/main/java/jadx/core/dex/visitors/MethodInlineVisitor.java | githubXiaowangzi/aa_reverse | f938da545fd93ef9bac9b32f2af88fe9d3916d7d | [
"Apache-2.0"
] | 4 | 2020-04-20T17:41:00.000Z | 2022-02-06T17:46:24.000Z | 32.011236 | 93 | 0.710425 | 3,848 | package jadx.core.dex.visitors;
import jadx.core.dex.attributes.AFlag;
import jadx.core.dex.attributes.nodes.MethodInlineAttr;
import jadx.core.dex.info.AccessInfo;
import jadx.core.dex.instructions.InsnType;
import jadx.core.dex.instructions.args.ArgType;
import jadx.core.dex.instructions.args.InsnArg;
import jadx.core.dex.instructions.args.RegisterArg;
import jadx.core.dex.nodes.BlockNode;
import jadx.core.dex.nodes.InsnNode;
import jadx.core.dex.nodes.MethodNode;
//import jadx.core.utils.exceptions.JadxException;
import java.util.List;
import jadx.exception.JadxException;
import jadx.core.dex.instructions.InvokeNode;
import android.util.Log;
/**
* Inline synthetic methods.
*/
public class MethodInlineVisitor extends AbstractVisitor {
@Override
public void visit(MethodNode mth) throws JadxException {
AccessInfo accessFlags = mth.getAccessFlags();
if (accessFlags.isSynthetic()
&& accessFlags.isStatic()
&& mth.getBasicBlocks().size() == 2) {
BlockNode returnBlock = mth.getBasicBlocks().get(1);
if (returnBlock.contains(AFlag.RETURN) || returnBlock.getInstructions().isEmpty()) {
BlockNode firstBlock = mth.getBasicBlocks().get(0);
inlineMth(mth, firstBlock, returnBlock);
}
}
}
private static void inlineMth(MethodNode mth, BlockNode firstBlock, BlockNode returnBlock) {
List<InsnNode> insnList = firstBlock.getInstructions();
if (insnList.isEmpty()) {
// synthetic field getter
BlockNode block = mth.getBasicBlocks().get(1);
InsnNode insn = block.getInstructions().get(0);
// set arg from 'return' instruction
addInlineAttr(mth, InsnNode.wrapArg(insn.getArg(0)));
return;
}
// synthetic field setter or method invoke
if (insnList.size() == 1) {
addInlineAttr(mth, insnList.get(0));
return;
}
// other field operations
if (insnList.size() == 2
&& returnBlock.getInstructions().size() == 1
&& !mth.getReturnType().equals(ArgType.VOID)) {
InsnNode get = insnList.get(0);
InsnNode put = insnList.get(1);
InsnArg retArg = returnBlock.getInstructions().get(0).getArg(0);
if (get.getType() == InsnType.IGET
&& put.getType() == InsnType.IPUT
&& retArg.isRegister()
&& get.getResult().equalRegisterAndType((RegisterArg) retArg)) {
RegisterArg retReg = (RegisterArg) retArg;
retReg.getSVar().removeUse(retReg);
CodeShrinker.shrinkMethod(mth);
insnList = firstBlock.getInstructions();
if (insnList.size() == 1) {
addInlineAttr(mth, insnList.get(0));
}
}
}
}
public static InsnNode wrapArg(InsnArg arg) {
InsnNode insn = new InsnNode(InsnType.ONE_ARG, 1);
insn.addArg(arg);
return insn;
}
private static void addInlineAttr(MethodNode mth, InsnNode insn) {
mth.addAttr(new MethodInlineAttr(insn));
mth.add(AFlag.DONT_GENERATE);
}
}
|
3e091414cb41db49080fe10830127d86b931431c | 1,930 | java | Java | src/main/java/me/dpohvar/powernbt/command/action/ActionView.java | DPOH-VAR/PowerNBT | 03795d6725b58500fe43ebc4e634f19e810c273e | [
"MIT"
] | 22 | 2015-01-17T08:39:26.000Z | 2021-06-08T06:17:17.000Z | src/main/java/me/dpohvar/powernbt/command/action/ActionView.java | DPOH-VAR/PowerNBT | 03795d6725b58500fe43ebc4e634f19e810c273e | [
"MIT"
] | 23 | 2015-01-25T17:09:47.000Z | 2021-12-05T03:32:15.000Z | src/main/java/me/dpohvar/powernbt/command/action/ActionView.java | DPOH-VAR/PowerNBT | 03795d6725b58500fe43ebc4e634f19e810c273e | [
"MIT"
] | 32 | 2015-02-16T07:24:58.000Z | 2021-06-14T20:08:58.000Z | 30.15625 | 131 | 0.57772 | 3,849 | package me.dpohvar.powernbt.command.action;
import me.dpohvar.powernbt.nbt.NBTContainer;
import me.dpohvar.powernbt.utils.Caller;
import me.dpohvar.powernbt.utils.NBTQuery;
import me.dpohvar.powernbt.utils.NBTViewer;
public class ActionView extends Action {
private final Caller caller;
private final Argument arg;
private String[] args;
private ActionView(Caller caller, String object, String query) {
this.caller = caller;
this.arg = new Argument(caller, object, query);
}
public ActionView(Caller caller, String object, String query, String args) {
this(caller, object, query);
if(args!=null) this.args = args.split(",|\\.|-");
}
@Override
public void execute() throws Exception {
if (arg.needPrepare()) {
arg.prepare(this, null, null);
return;
}
NBTContainer container = arg.getContainer();
NBTQuery query = arg.getQuery();
int start=-1, end=-1;
boolean hex = false;
boolean bin = false;
if(args!=null) {
for(String s:args){
if (s.equalsIgnoreCase("hex")||s.equalsIgnoreCase("h")) hex=true;
if (s.equalsIgnoreCase("bin")||s.equalsIgnoreCase("b")) bin=true;
else if (s.equalsIgnoreCase("full")||s.equalsIgnoreCase("f")||s.equalsIgnoreCase("all")||s.equalsIgnoreCase("a")) {
start=0; end=Integer.MAX_VALUE;
}
else if (s.matches("[0-9]+")){
if(end==-1) end = Integer.parseInt(s);
else start = Integer.parseInt(s);
}
}
}
if(start==-1) start=0;
if(end==-1) end=0;
if(start>end){int t=start; start=end; end=t;}
String answer = NBTViewer.getFullValue(container.getCustomTag(query), start, end, hex, bin);
caller.send(answer);
}
}
|
3e0914324c248f92327429e56f62322dffdf862f | 1,321 | java | Java | src/main/java/com/zup/mercado/categoria/CategoriaRequest.java | gomesmr/orange-talents-08-template-ecommerce | e51736f0a025d2b6cf9b1589b9f119cf47736120 | [
"Apache-2.0"
] | null | null | null | src/main/java/com/zup/mercado/categoria/CategoriaRequest.java | gomesmr/orange-talents-08-template-ecommerce | e51736f0a025d2b6cf9b1589b9f119cf47736120 | [
"Apache-2.0"
] | null | null | null | src/main/java/com/zup/mercado/categoria/CategoriaRequest.java | gomesmr/orange-talents-08-template-ecommerce | e51736f0a025d2b6cf9b1589b9f119cf47736120 | [
"Apache-2.0"
] | null | null | null | 27.520833 | 106 | 0.700227 | 3,850 | package com.zup.mercado.categoria;
import com.zup.mercado.config.validator.UniqueValue;
import org.aspectj.bridge.IMessage;
import org.springframework.util.Assert;
import javax.persistence.EntityManager;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Positive;
import java.nio.file.Files;
import java.util.List;
import java.util.Optional;
public class CategoriaRequest {
@UniqueValue(domainClass = Categoria.class, fieldName = "nome", message = "Essa categoria já existe.")
@NotBlank
private String nome;
@Positive
private Long idCategoriaMae;
public Categoria toModel(EntityManager manager) {
Categoria categoria = new Categoria(nome);
if (idCategoriaMae != null){
Categoria categoriaMae = manager.find(Categoria.class, idCategoriaMae);
Assert.notNull(categoriaMae, "O id da categoria mae precisa ser válido.");
categoria.setMae(categoriaMae);
}
return categoria;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public Long getIdCategoriaMae() {
return idCategoriaMae;
}
public void setIdCategoriaMae(Long idCategoriaMae) {
this.idCategoriaMae = idCategoriaMae;
}
}
|
3e09148a6359c3867d86880b2dfed49206ea9b52 | 837 | java | Java | com.softicar.sqml.model/src/main/java/com/softicar/sqml/model/tables/validation/SqmlIssueIllegalBitsAttribute.java | softicar/sqml | d10deb5ff5b5c79aa56e867bda32052d66a2295d | [
"MIT"
] | null | null | null | com.softicar.sqml.model/src/main/java/com/softicar/sqml/model/tables/validation/SqmlIssueIllegalBitsAttribute.java | softicar/sqml | d10deb5ff5b5c79aa56e867bda32052d66a2295d | [
"MIT"
] | null | null | null | com.softicar.sqml.model/src/main/java/com/softicar/sqml/model/tables/validation/SqmlIssueIllegalBitsAttribute.java | softicar/sqml | d10deb5ff5b5c79aa56e867bda32052d66a2295d | [
"MIT"
] | null | null | null | 28.862069 | 96 | 0.811231 | 3,851 | package com.softicar.sqml.model.tables.validation;
import com.softicar.sqml.model.tables.ISqmlTableColumn;
import com.softicar.sqml.model.tables.TablesPackage;
import com.softicar.sqml.model.types.ISqmlType;
import com.softicar.sqml.model.validation.AbstractSqmlError;
import org.eclipse.emf.ecore.EStructuralFeature;
public class SqmlIssueIllegalBitsAttribute extends AbstractSqmlError<ISqmlTableColumn> {
public SqmlIssueIllegalBitsAttribute(ISqmlTableColumn tableColumn) {
super(tableColumn);
}
@Override
public EStructuralFeature getStructuralFeature() {
return TablesPackage.eINSTANCE.getSqmlTableColumn_Bits();
}
@Override
public String getMessage() {
ISqmlType columnType = getTargetObject().getSqmlType();
return String.format("The BITS attribute may not be used on columns of type %s.", columnType);
}
}
|
3e09162f561b1dc2bbb54472f1a0d24cd05dae22 | 169 | java | Java | src/main/java/org/activiti/cloud/qa/service/ProcessingService.java | miguelruizdev/ttc-acceptance-tests | 9ec7807213d4a035feedb885f2b31c49523ac9a3 | [
"Apache-2.0"
] | 1 | 2020-05-29T07:47:45.000Z | 2020-05-29T07:47:45.000Z | src/main/java/org/activiti/cloud/qa/service/ProcessingService.java | miguelruizdev/ttc-acceptance-tests | 9ec7807213d4a035feedb885f2b31c49523ac9a3 | [
"Apache-2.0"
] | 178 | 2018-09-18T13:05:12.000Z | 2019-11-01T14:24:15.000Z | src/main/java/org/activiti/cloud/qa/service/ProcessingService.java | miguelruizdev/ttc-acceptance-tests | 9ec7807213d4a035feedb885f2b31c49523ac9a3 | [
"Apache-2.0"
] | 3 | 2018-09-06T08:14:06.000Z | 2020-06-05T10:28:29.000Z | 15.363636 | 56 | 0.739645 | 3,852 | package org.activiti.cloud.qa.service;
/**
* Processing service
*/
public interface ProcessingService extends BaseService {
String campaignName = "activiti";
}
|
3e091648ffa6b6b4baf09a58830da5b9a025e1c1 | 1,860 | java | Java | onvif-ws-client/src/main/java/org/onvif/ver10/schema/ReceiverMode.java | danielmorse/onvif | db421afb2c3e8957e3e31b76072cc4ad64e8074b | [
"Apache-2.0"
] | 126 | 2017-01-14T09:16:46.000Z | 2022-03-16T02:25:56.000Z | onvif-ws-client/src/main/java/org/onvif/ver10/schema/ReceiverMode.java | love208-vip/onvif | 97066a94f1c5d9d8f285b7e93fc95703da16aee7 | [
"Apache-2.0"
] | 20 | 2017-02-03T19:57:22.000Z | 2021-04-27T07:34:55.000Z | onvif-ws-client/src/main/java/org/onvif/ver10/schema/ReceiverMode.java | love208-vip/onvif | 97066a94f1c5d9d8f285b7e93fc95703da16aee7 | [
"Apache-2.0"
] | 63 | 2016-06-15T13:42:03.000Z | 2022-03-11T07:47:01.000Z | 22.682927 | 95 | 0.597849 | 3,853 |
package org.onvif.ver10.schema;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ReceiverMode.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* <simpleType name="ReceiverMode">
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="AutoConnect"/>
* <enumeration value="AlwaysConnect"/>
* <enumeration value="NeverConnect"/>
* <enumeration value="Unknown"/>
* </restriction>
* </simpleType>
* </pre>
*
*/
@XmlType(name = "ReceiverMode")
@XmlEnum
public enum ReceiverMode {
/**
* The receiver connects on demand, as required by consumers of the media
* streams.
*
*
*/
@XmlEnumValue("AutoConnect")
AUTO_CONNECT("AutoConnect"),
/**
* The receiver attempts to maintain a persistent connection to the
* configured endpoint.
*
*
*/
@XmlEnumValue("AlwaysConnect")
ALWAYS_CONNECT("AlwaysConnect"),
/**
* The receiver does not attempt to connect.
*
*/
@XmlEnumValue("NeverConnect")
NEVER_CONNECT("NeverConnect"),
/**
* This case should never happen.
*
*/
@XmlEnumValue("Unknown")
UNKNOWN("Unknown");
private final String value;
ReceiverMode(String v) {
value = v;
}
public String value() {
return value;
}
public static ReceiverMode fromValue(String v) {
for (ReceiverMode c: ReceiverMode.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
|
3e09165248a2ba7d0b4668ba51b581cc84511b7f | 191 | java | Java | lemon-cloud-framework/lemon-cloud-mybatis/src/main/java/com/lemon/cloud/mybatis/configuration/MybatisPlusConfiguration.java | mazhilin/lemon-cloud-platform | f9cdfeeb2b07dc587ab77d5cab7f5cb3c554eee5 | [
"Apache-2.0"
] | null | null | null | lemon-cloud-framework/lemon-cloud-mybatis/src/main/java/com/lemon/cloud/mybatis/configuration/MybatisPlusConfiguration.java | mazhilin/lemon-cloud-platform | f9cdfeeb2b07dc587ab77d5cab7f5cb3c554eee5 | [
"Apache-2.0"
] | null | null | null | lemon-cloud-framework/lemon-cloud-mybatis/src/main/java/com/lemon/cloud/mybatis/configuration/MybatisPlusConfiguration.java | mazhilin/lemon-cloud-platform | f9cdfeeb2b07dc587ab77d5cab7f5cb3c554eee5 | [
"Apache-2.0"
] | null | null | null | 19.1 | 60 | 0.811518 | 3,854 | package com.lemon.cloud.mybatis.configuration;
import org.springframework.context.annotation.Configuration;
/** @author marklin */
@Configuration
public class MybatisPlusConfiguration {
}
|
3e0916c2f34c7c0f63824e57726529d97cc5d6cc | 1,659 | java | Java | edu/cmu/lti/util/html/FCharter.java | whwang1996/pra | 9db550f0a169ad2106ac6fb031b9fdd0d22fec65 | [
"MIT"
] | 61 | 2018-02-05T06:43:53.000Z | 2022-03-12T12:56:47.000Z | edu/cmu/lti/util/html/FCharter.java | irokin/Path-Ranking-Algorithms | ed8daeebb039a78ea10872e1f7505d00fdd5fcff | [
"MIT"
] | 8 | 2018-03-25T02:46:42.000Z | 2020-09-19T08:31:38.000Z | edu/cmu/lti/util/html/FCharter.java | irokin/Path-Ranking-Algorithms | ed8daeebb039a78ea10872e1f7505d00fdd5fcff | [
"MIT"
] | 23 | 2017-08-17T08:14:45.000Z | 2021-11-11T09:17:52.000Z | 22.726027 | 61 | 0.650995 | 3,855 | /**
*
*/
package edu.cmu.lti.util.html;
import java.util.Map;
import edu.cmu.lti.algorithm.container.MapIS;
import edu.cmu.lti.algorithm.container.MapIMapIS;
import edu.cmu.lti.algorithm.container.MapISetI;
import edu.cmu.lti.algorithm.container.SetI;
import edu.cmu.lti.algorithm.container.MapIX;
import edu.cmu.lti.algorithm.container.VectorI;
import edu.cmu.lti.algorithm.container.VecVecI;
/**
* @author nlao
* this class arrange blocks into a width-fixed table
*/
public class FCharter{
private int chartWidth;
VecVecI vvi= new VecVecI();
public FCharter(int chartWidth){
this.chartWidth = chartWidth;
}
/**
* sample:
* |AA| |B|CCC| | becomes
* 2, -1, 0, 0, 1, 3,-1,-1, 0
* @param mm
* @return: vvi: each cell point to its text
*/
public VecVecI doChart(MapISetI mm ){
for (Map.Entry<Integer, SetI> e: mm.entrySet()){
int len = e.getKey();
for (Integer ib: e.getValue())
insert(len, ib);
}
return vvi;
}
public VecVecI doChart(MapIMapIS mms ){
for (Map.Entry<Integer, MapIX<String> > e: mms.entrySet()){
int len = e.getKey();
for (Integer ib: e.getValue().keySet())
insert(len, ib);
}
return vvi;
}
private void insert(int len, int ib ){
for (VectorI vi: vvi){
if(tryInsert(len, ib, vi))
return;
}
VectorI vi = new VectorI(chartWidth,0);
vvi.add(vi);
insert( len, ib, vi);
}
private boolean tryInsert(int len, int ib, VectorI vi){
for (int i=ib; i< ib+len; ++i)
if (vi.get(i)!=0)
return false;
insert( len, ib, vi);
return true;
}
private void insert(int len, int ib, VectorI vi){
vi.setRange(ib, ib+len, -1);
vi.set(ib, len);
}
} |
3e0918efd87766b8ee726ae95fde6077896e4142 | 426 | java | Java | src/main/java/dp/generatorapi/controller/ExportForm.java | ONSdigital/dp-generator-api | 61b3e43eccc8a3dbc041dd5db280f68a7ed0d5a5 | [
"MIT"
] | null | null | null | src/main/java/dp/generatorapi/controller/ExportForm.java | ONSdigital/dp-generator-api | 61b3e43eccc8a3dbc041dd5db280f68a7ed0d5a5 | [
"MIT"
] | null | null | null | src/main/java/dp/generatorapi/controller/ExportForm.java | ONSdigital/dp-generator-api | 61b3e43eccc8a3dbc041dd5db280f68a7ed0d5a5 | [
"MIT"
] | 1 | 2021-04-11T08:18:55.000Z | 2021-04-11T08:18:55.000Z | 15.777778 | 42 | 0.607981 | 3,856 | package dp.generatorapi.controller;
import java.util.List;
public class ExportForm {
private String format;
private List<String> url;
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public List<String> getUrl() {
return url;
}
public void setUrl(List<String> url) {
this.url = url;
}
}
|
3e091ac40885679b0fedfd1053c191338936edf9 | 3,291 | java | Java | src/test/java/com/thomaspwilson/oauth2/provider/flows/ClientCredentialsFlowTest.java | thomas-p-wilson/oauth.java | 2061c1b3566a038dc229bb87104b2c866232336b | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | src/test/java/com/thomaspwilson/oauth2/provider/flows/ClientCredentialsFlowTest.java | thomas-p-wilson/oauth.java | 2061c1b3566a038dc229bb87104b2c866232336b | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | src/test/java/com/thomaspwilson/oauth2/provider/flows/ClientCredentialsFlowTest.java | thomas-p-wilson/oauth.java | 2061c1b3566a038dc229bb87104b2c866232336b | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | 39.650602 | 100 | 0.714069 | 3,857 | /**
* 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.thomaspwilson.oauth2.provider.flows;
import com.thomaspwilson.oauth2.provider.AbstractTest;
import static com.thomaspwilson.oauth2.provider.AbstractTest.CLIENT_A;
import com.thomaspwilson.oauth2.provider.exception.UnauthorizedClientException;
import com.thomaspwilson.oauth2.provider.io.Request;
import com.thomaspwilson.oauth2.provider.model.AccessToken;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import org.joda.time.DateTime;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ClientCredentialsFlowTest extends AbstractTest {
private static final Logger LOGGER = LoggerFactory.getLogger(ClientCredentialsFlowTest.class);
@Test
public void ensureCanBeSuccessful() {
AccessToken at = accessTokenManager.request(request());
assertThat(at.getClientId(), is(equalTo("client_a")));
assertThat(at.getUserId(), is(nullValue()));
assertThat(at.getRefreshTokenId(), is(nullValue()));
assertThat(at.getTokenId(), is(notNullValue()));
assertThat(at.getTokenType(), is(equalTo("bearer")));
assertThat(new DateTime().getMillis() - at.getIssueTime().getMillis(), is(lessThan(1000L)));
}
@Test
public void ensureNonConfidentialClientCannotUse() {
THROWN.expect(UnauthorizedClientException.class);
THROWN.expectMessage("Public client not authorized to use client_credentials grant type");
Request request = request()
.setClientId(CLIENT_C.getId())
.setClientSecret(CLIENT_C.getSecret());
accessTokenManager.request(request);
fail("Should have thrown exception");
}
@Override
protected String[] getRequiredFields() {
return new String[]{
"client_id", "client_secret"
};
}
@Override
protected Map<String, List<String>> getRequestHeaders() {
return new HashMap<String, List<String>>(){{
put("Authorization", Collections.singletonList("Basic "+base64(CLIENT_A)));
}};
}
@Override
protected Map<String, List<String>> getRequestParameters() {
return new HashMap<String, List<String>>(){{
put("grant_type", Collections.singletonList("client_credentials"));
put("scope", Collections.singletonList("profile"));
}};
}
}
|
3e091b2b64e38ab07adc2bf626b8cc385d82a595 | 1,141 | java | Java | 1-evosuite-fuzzer/master/src/test/java/com/examples/with/different/packagename/mock/java/lang/SourceExceptions.java | mitchellolsthoorn/ASE-NIER-2020-Replication | d921c324d95346b2d962d913c21b993fa5a51d18 | [
"MIT"
] | null | null | null | 1-evosuite-fuzzer/master/src/test/java/com/examples/with/different/packagename/mock/java/lang/SourceExceptions.java | mitchellolsthoorn/ASE-NIER-2020-Replication | d921c324d95346b2d962d913c21b993fa5a51d18 | [
"MIT"
] | 3 | 2020-11-16T20:45:46.000Z | 2021-03-23T00:28:18.000Z | 1-evosuite-fuzzer/master/src/test/java/com/examples/with/different/packagename/mock/java/lang/SourceExceptions.java | mitchellolsthoorn/ASE-NIER-2020-Replication | d921c324d95346b2d962d913c21b993fa5a51d18 | [
"MIT"
] | null | null | null | 28.525 | 75 | 0.697634 | 3,858 | /**
* Copyright (C) 2010-2018 Gordon Fraser, Andrea Arcuri and EvoSuite
* contributors
*
* This file is part of EvoSuite.
*
* EvoSuite is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* EvoSuite is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with EvoSuite. If not, see <http://www.gnu.org/licenses/>.
*/
package com.examples.with.different.packagename.mock.java.lang;
/**
* Created by Andrea Arcuri on 19/08/15.
*/
public class SourceExceptions {
public static class Foo{
public static void foo(){
throw new IllegalArgumentException();
}
}
public void bar(Integer x){
x.byteValue();
Foo.foo();
}
}
|
3e091b4636e27ff2e90dee9d4db2ec1919ac929c | 4,282 | java | Java | delta-test/src/main/java/io/cdap/delta/test/mock/FileEventConsumer.java | data-integrations/delta | ffc03a0e48e79b60ac62c46b0ac10c93a27511e9 | [
"Apache-2.0"
] | 4 | 2020-04-14T19:28:45.000Z | 2022-03-05T09:12:44.000Z | delta-test/src/main/java/io/cdap/delta/test/mock/FileEventConsumer.java | data-integrations/delta | ffc03a0e48e79b60ac62c46b0ac10c93a27511e9 | [
"Apache-2.0"
] | 65 | 2020-01-23T23:45:30.000Z | 2022-02-07T19:24:00.000Z | delta-test/src/main/java/io/cdap/delta/test/mock/FileEventConsumer.java | data-integrations/delta | ffc03a0e48e79b60ac62c46b0ac10c93a27511e9 | [
"Apache-2.0"
] | 2 | 2021-06-29T09:31:42.000Z | 2022-03-23T20:57:34.000Z | 35.983193 | 114 | 0.740308 | 3,859 | /*
* Copyright © 2020 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package io.cdap.delta.test.mock;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import io.cdap.cdap.api.data.format.StructuredRecord;
import io.cdap.cdap.api.data.schema.Schema;
import io.cdap.cdap.internal.io.SchemaTypeAdapter;
import io.cdap.delta.api.ChangeEvent;
import io.cdap.delta.api.DDLEvent;
import io.cdap.delta.api.DDLOperation;
import io.cdap.delta.api.DMLEvent;
import io.cdap.delta.api.DeltaTargetContext;
import io.cdap.delta.api.EventConsumer;
import io.cdap.delta.api.ReplicationError;
import io.cdap.delta.api.Sequenced;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Buffers events in memory, then writes them out to a file when the consumer is closed.
*/
public class FileEventConsumer implements EventConsumer {
private static final Gson GSON = new GsonBuilder()
.registerTypeAdapter(Schema.class, new SchemaTypeAdapter())
.registerTypeAdapter(StructuredRecord.class, new StructuredRecordSerde())
.registerTypeAdapter(ChangeEvent.class, new ChangeEventDeserializer())
.create();
private final File file;
private final List<ChangeEvent> events;
private final DeltaTargetContext context;
private final boolean emitErrorForDML;
private long latestSequenceNum;
FileEventConsumer(File file, DeltaTargetContext context, boolean emitErrorForDML) {
this.file = file;
this.events = new ArrayList<>();
this.context = context;
this.emitErrorForDML = emitErrorForDML;
this.latestSequenceNum = 0;
}
@Override
public void start() {
// no-op
}
@Override
public void stop() {
try (FileWriter writer = new FileWriter(file)) {
writer.write(GSON.toJson(events));
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
@Override
public void applyDDL(Sequenced<DDLEvent> event) throws IOException {
events.add(event.getEvent());
DDLOperation ddlOperation = event.getEvent().getOperation();
context.incrementCount(ddlOperation);
context.commitOffset(event.getEvent().getOffset(), latestSequenceNum);
context.setTableReplicating(event.getEvent().getOperation().getDatabaseName(), ddlOperation.getTableName());
}
@Override
public void applyDML(Sequenced<DMLEvent> event) throws IOException {
events.add(event.getEvent());
context.incrementCount(event.getEvent().getOperation());
if (emitErrorForDML) {
context.setTableError(event.getEvent().getOperation().getDatabaseName(),
event.getEvent().getOperation().getTableName(), new ReplicationError(new Exception()));
}
latestSequenceNum = event.getSequenceNumber();
context.commitOffset(event.getEvent().getOffset(), latestSequenceNum);
}
/**
* Read events that were consumed by the target. This should only be called after the pipeline has been stopped.
*
* @param filePath path to read events from
* @param instanceId instance id that wrote the events
* @return list of events contained in the file path
* @throws IOException if there was an issue reading the file
*/
public static List<? extends ChangeEvent> readEvents(File filePath, int instanceId) throws IOException {
File eventsFile = new File(filePath, String.format("%d.json", instanceId));
if (!eventsFile.exists()) {
return Collections.emptyList();
}
try (Reader reader = new FileReader(eventsFile)) {
return GSON.fromJson(reader, new TypeToken<List<? extends ChangeEvent>>() { }.getType());
}
}
}
|
3e091ccd2a8296773e4205ea92cf3147f19588b0 | 92,750 | java | Java | tests/time/qmosa/tests/s1014/92_jcvi-javacommon/evosuite-tests/org/jcvi/jillion/core/Range_ESTest.java | sealuzh/termite-replication | 1636b1973c8692ed6a818e323cd1dd826cabbad3 | [
"MIT"
] | null | null | null | tests/time/qmosa/tests/s1014/92_jcvi-javacommon/evosuite-tests/org/jcvi/jillion/core/Range_ESTest.java | sealuzh/termite-replication | 1636b1973c8692ed6a818e323cd1dd826cabbad3 | [
"MIT"
] | 3 | 2020-11-16T20:40:56.000Z | 2021-03-23T00:18:04.000Z | tests/time/qmosa/tests/s1014/92_jcvi-javacommon/evosuite-tests/org/jcvi/jillion/core/Range_ESTest.java | sealuzh/termite-replication | 1636b1973c8692ed6a818e323cd1dd826cabbad3 | [
"MIT"
] | null | null | null | 34.907791 | 176 | 0.649509 | 3,860 | /*
* This file was automatically generated by EvoSuite
* Mon Nov 30 01:36:06 GMT 2020
*/
package org.jcvi.jillion.core;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.evosuite.shaded.org.mockito.Mockito.*;
import static org.evosuite.runtime.EvoAssertions.*;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.evosuite.runtime.ViolatedAssumptionAnswer;
import org.jcvi.jillion.core.Range;
import org.junit.runner.RunWith;
@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true, useJEE = true)
public class Range_ESTest extends Range_ESTest_scaffolding {
/**
//Test case number: 0
/*Coverage entropy=3.360463764209726
*/
@Test(timeout = 4000)
public void test00() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(78L, 65535L);
range_Builder0.copy();
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
long long0 = 1351L;
Range range0 = Range.of(range_CoordinateSystem0, 78L, 1351L);
linkedList0.pollFirst();
Object[] objectArray0 = new Object[7];
objectArray0[0] = (Object) range_CoordinateSystem0;
objectArray0[1] = (Object) range0;
objectArray0[2] = (Object) range_Builder0;
objectArray0[3] = (Object) range_CoordinateSystem0;
Range.of(1351L);
Range range1 = Range.of(range_CoordinateSystem0, 65535L, 65535L);
Long long1 = Long.valueOf(557L);
range1.equals(long1);
long long2 = 255L;
// Undeclared exception!
try {
Range.of(4122L, 255L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 1
/*Coverage entropy=3.3254614353123833
*/
@Test(timeout = 4000)
public void test01() throws Throwable {
long long0 = 65535L;
Range.Builder range_Builder0 = new Range.Builder(110L, 65535L);
range_Builder0.copy();
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 110L, 1351L);
linkedList0.pollFirst();
Object[] objectArray0 = new Object[7];
objectArray0[0] = (Object) range_CoordinateSystem0;
objectArray0[1] = (Object) range0;
objectArray0[2] = (Object) range_Builder0;
Consumer<Object> consumer0 = (Consumer<Object>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
Range.of(1351L, 65535L);
// Undeclared exception!
try {
range0.isSubRangeOf((Range) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// range can not be null
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 2
/*Coverage entropy=3.115475024880771
*/
@Test(timeout = 4000)
public void test02() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
long long0 = (-145L);
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-145L), 127L);
long long1 = (-3786L);
range_Builder0.shift((-3786L));
long long2 = 1L;
Range range0 = Range.ofLength(264L);
Range range1 = null;
// Undeclared exception!
try {
range0.complement((Range) null);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// Null Range used in intersection operation.
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 3
/*Coverage entropy=3.530434671595211
*/
@Test(timeout = 4000)
public void test03() throws Throwable {
long long0 = 1871L;
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
long long1 = (-145L);
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-145L), 127L);
Range.Builder range_Builder1 = range_Builder0.shift((-3786L));
Range range0 = Range.of(3L, 1871L);
range_Builder0.copy();
range_Builder1.shift((-5505L));
Consumer<Object> consumer0 = (Consumer<Object>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
Object object0 = new Object();
range0.equals(object0);
Range range1 = Range.of(9223372032559808513L);
List<Range> list0 = range1.split(714L);
range1.complementFrom(list0);
range1.equals(range_Builder1);
long long2 = 2346L;
Range.Builder range_Builder2 = null;
try {
range_Builder2 = new Range.Builder(2346L, (-5505L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 4
/*Coverage entropy=3.4960136386402008
*/
@Test(timeout = 4000)
public void test04() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder((-3610L), (-3610L));
Range.Builder range_Builder1 = new Range.Builder(1276L, 1276L);
Range.Builder range_Builder2 = new Range.Builder();
range_Builder0.expandEnd((-3610L));
Range.Builder range_Builder3 = range_Builder1.expandBegin((-1L));
Range range0 = Range.of((-1L));
range0.equals(range_Builder3);
Range.Builder range_Builder4 = new Range.Builder(range_Builder3);
Range range1 = Range.ofLength(275L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
range1.getEnd(range_CoordinateSystem0);
Range.of((-1L), 127L);
range1.intersects(range0);
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.RESIDUE_BASED;
Range.Builder range_Builder5 = null;
try {
range_Builder5 = new Range.Builder(range_CoordinateSystem1, 993L, (-721L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 5
/*Coverage entropy=2.7886260379670387
*/
@Test(timeout = 4000)
public void test05() throws Throwable {
Range range0 = Range.ofLength(9223372036854775807L);
range0.toString();
// Undeclared exception!
try {
range0.startsBefore((Range) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// Null Range used in range comparison operation.
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 6
/*Coverage entropy=3.718025988857895
*/
@Test(timeout = 4000)
public void test06() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(78L, 65535L);
Range.Builder range_Builder1 = range_Builder0.copy();
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 78L, 1351L);
Object[] objectArray0 = new Object[7];
objectArray0[0] = (Object) range_CoordinateSystem0;
objectArray0[1] = (Object) range0;
objectArray0[2] = (Object) range_Builder0;
Object object0 = new Object();
objectArray0[3] = object0;
objectArray0[4] = (Object) range0;
objectArray0[5] = (Object) range_Builder0;
objectArray0[6] = (Object) linkedList0;
linkedList0.toArray(objectArray0);
linkedList0.addFirst(range0);
List<Range> list0 = range0.complementFrom(linkedList0);
range_Builder1.expandBegin(78L);
Range.of(1855L);
range0.equals(list0);
Range.Builder range_Builder2 = new Range.Builder(range_Builder0);
range_Builder1.shift(9223372036854775807L);
Range.of((-133L), 32767L);
// Undeclared exception!
try {
Range.of(3975L, 1863L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 7
/*Coverage entropy=3.7090435437527334
*/
@Test(timeout = 4000)
public void test07() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-145L), 106L);
Range.Builder range_Builder1 = range_Builder0.shift((-3786L));
Range range0 = Range.of(3L, 1871L);
range_Builder0.copy();
range_Builder1.shift(1744L);
Range range1 = Range.of(3L, 1744L);
Consumer<Object> consumer0 = (Consumer<Object>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
Range range2 = range0.intersection(range1);
range_Builder0.copy();
Range range3 = Range.of((-469L));
range0.startsBefore(range3);
List<Range> list0 = range2.split(2L);
range0.getBegin();
Range range4 = range2.asRange();
// Undeclared exception!
range4.complementFrom(list0);
}
/**
//Test case number: 8
/*Coverage entropy=-0.0
*/
@Test(timeout = 4000)
public void test08() throws Throwable {
Range range0 = null;
Range.Builder range_Builder0 = null;
try {
range_Builder0 = new Range.Builder((Range) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// range can not be null
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 9
/*Coverage entropy=3.529060630972935
*/
@Test(timeout = 4000)
public void test09() throws Throwable {
Range range0 = Range.ofLength(929L);
range0.getEnd();
long long0 = 0L;
Range.ofLength(0L);
Range range1 = Range.of(499L, 2371L);
long long1 = (-929L);
long long2 = 1865L;
List<Range> list0 = range1.split(1865L);
range0.complementFrom(list0);
long long3 = (-337L);
// Undeclared exception!
try {
Range.of(4294967295L, (-337L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 10
/*Coverage entropy=3.450201148079376
*/
@Test(timeout = 4000)
public void test10() throws Throwable {
long long0 = (-469L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-145L), 127L);
Range.Builder range_Builder1 = range_Builder0.shift((-3783L));
Range.of(3L, 1871L);
range_Builder0.copy();
range_Builder1.shift(1768L);
Consumer<Object> consumer0 = (Consumer<Object>) mock(Consumer.class, new ViolatedAssumptionAnswer());
Range.of(range_CoordinateSystem0, (-3783L), (-145L));
Range range0 = Range.of(1855L, 2623L);
long long1 = 9223372036854775382L;
Range.of(3L);
Range range1 = null;
// Undeclared exception!
try {
range0.endsBefore((Range) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// Null Range used in range comparison operation.
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 11
/*Coverage entropy=3.158039775219435
*/
@Test(timeout = 4000)
public void test11() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(9L, 9223372036854775807L);
long long0 = (-1L);
range_Builder0.expandEnd(9L);
long long1 = 4294967295L;
range_Builder0.expandBegin(9223372036854775807L);
long long2 = 62790L;
Range range0 = Range.ofLength(9L);
// Undeclared exception!
try {
range0.complementFrom((Collection<Range>) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// no message in exception (getMessage() returned null)
//
verifyException("java.util.ArrayList", e);
}
}
/**
//Test case number: 12
/*Coverage entropy=3.320362323039676
*/
@Test(timeout = 4000)
public void test12() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder((-1L), 575L);
Range range0 = Range.ofLength(575L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.Builder range_Builder1 = new Range.Builder(range0);
Range.Builder range_Builder2 = range_Builder1.contractBegin(575L);
Range.Builder range_Builder3 = range_Builder0.contractEnd(478L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.RESIDUE_BASED;
range0.getBegin(range_CoordinateSystem1);
Range range1 = Range.ofLength(1782L);
range_Builder2.expandBegin(1253L);
range0.isSubRangeOf(range1);
range_Builder3.shift(32767L);
long long0 = (-50L);
long long1 = (-3287L);
// Undeclared exception!
try {
Range.of(range_CoordinateSystem0, (-50L), (-3287L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 13
/*Coverage entropy=3.548614617774235
*/
@Test(timeout = 4000)
public void test13() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(575L);
Range.Builder range_Builder1 = new Range.Builder((-1L), 575L);
Range range0 = Range.of((-1L), 7L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.Builder range_Builder2 = new Range.Builder(range0);
Range.Builder range_Builder3 = new Range.Builder(range0);
range_Builder2.contractEnd((-74L));
Range.ofLength(1864L);
range_Builder0.expandEnd((-74L));
Range range1 = Range.ofLength(7L);
Range.ofLength(1853L);
Range range2 = Range.ofLength(65535L);
range2.complement(range1);
Range range3 = Range.ofLength(2048L);
range3.split(7L);
range0.intersection(range2);
Range.Comparators.values();
// Undeclared exception!
try {
Range.CoordinateSystem.valueOf("");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.CoordinateSystem.
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 14
/*Coverage entropy=3.468104785350768
*/
@Test(timeout = 4000)
public void test14() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(78L, 65535L);
Range.Builder range_Builder1 = range_Builder0.copy();
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 78L, 1351L);
linkedList0.pollFirst();
Object[] objectArray0 = new Object[7];
objectArray0[0] = (Object) range_CoordinateSystem0;
objectArray0[1] = (Object) range0;
objectArray0[2] = (Object) range_Builder0;
objectArray0[3] = objectArray0[0];
objectArray0[4] = (Object) range0;
objectArray0[5] = (Object) range_Builder0;
objectArray0[6] = (Object) linkedList0;
linkedList0.toArray(objectArray0);
linkedList0.addFirst(range0);
List<Range> list0 = range0.complementFrom(linkedList0);
LinkedList<Range> linkedList1 = new LinkedList<Range>(list0);
LinkedList<Range> linkedList2 = new LinkedList<Range>();
long long0 = (-1445L);
range_Builder1.shift((-1445L));
Range.of(78L, 65535L);
// Undeclared exception!
try {
range0.intersects((Range) null);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// Null Range used in intersection operation.
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 15
/*Coverage entropy=3.470871826271397
*/
@Test(timeout = 4000)
public void test15() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
long long0 = 131L;
Range range0 = Range.of(131L, 131L);
range0.equals(range_CoordinateSystem0);
Range range1 = Range.of(131L);
Range range2 = Range.of(131L);
range1.equals(range2);
Range.Builder range_Builder0 = new Range.Builder(131L, 131L);
Consumer<Long> consumer0 = (Consumer<Long>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range2.forEach(consumer0);
range2.isSubRangeOf(range1);
Range.of(2346L);
long long1 = 32767L;
Range range3 = Range.of(3000L, 3000L);
range3.intersection(range2);
Range.Comparators.values();
// Undeclared exception!
try {
Range.CoordinateSystem.valueOf("");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.CoordinateSystem.
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 16
/*Coverage entropy=3.227325011951738
*/
@Test(timeout = 4000)
public void test16() throws Throwable {
long long0 = 78L;
long long1 = 4294967295L;
Range range0 = Range.of(2424L, 4294967295L);
range0.equals((Object) null);
Range range1 = Range.of(600L);
long long2 = 32767L;
Range.of(32767L);
range1.equals(range0);
Range.Builder range_Builder0 = null;
try {
range_Builder0 = new Range.Builder(181L, 78L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 17
/*Coverage entropy=3.1686218118634186
*/
@Test(timeout = 4000)
public void test17() throws Throwable {
Range range0 = Range.ofLength(0L);
Long long0 = new Long(0L);
boolean boolean0 = range0.equals((Object) null);
range0.getBegin();
boolean boolean1 = range0.isEmpty();
assertFalse(boolean1 == boolean0);
Range range1 = Range.of(0L);
range0.intersects(range1);
boolean boolean2 = range1.endsBefore(range0);
boolean boolean3 = range0.intersects(range1);
assertTrue(boolean3 == boolean2);
Range range2 = Range.ofLength(0L);
assertSame(range2, range0);
}
/**
//Test case number: 18
/*Coverage entropy=3.634746542619924
*/
@Test(timeout = 4000)
public void test18() throws Throwable {
Range range0 = Range.ofLength(929L);
range0.getEnd();
Range.ofLength(0L);
Range range1 = Range.of(499L, 2371L);
List<Range> list0 = range1.split(1865L);
range0.complementFrom(list0);
Range.Builder range_Builder0 = new Range.Builder();
range_Builder0.build();
Range.Builder range_Builder1 = new Range.Builder(range_Builder0);
Range.Builder range_Builder2 = range_Builder0.shift(0L);
long long0 = 2089L;
Range.of(0L, 715L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range.Builder range_Builder3 = new Range.Builder(range_CoordinateSystem0, (-1454L), 1350L);
Range.Builder range_Builder4 = new Range.Builder(573L);
Range.Builder range_Builder5 = new Range.Builder(range_Builder3);
range_Builder2.contractBegin((-929L));
LinkedList<Range> linkedList0 = new LinkedList<Range>();
// Undeclared exception!
try {
Range.parseRange((String) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// no message in exception (getMessage() returned null)
//
}
}
/**
//Test case number: 19
/*Coverage entropy=3.675193168580467
*/
@Test(timeout = 4000)
public void test19() throws Throwable {
Range range0 = Range.of(4138L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(255L, 255L);
range0.isSubRangeOf(range1);
Range range2 = Range.of(range_CoordinateSystem0, 4138L, 4138L);
Range range3 = range2.intersection(range0);
range2.isEmpty();
range2.toString();
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.RESIDUE_BASED;
Range range4 = Range.of(range_CoordinateSystem1, 4138L, 4138L);
Range range5 = Range.of((-2013L), 4138L);
Range.CoordinateSystem range_CoordinateSystem2 = Range.CoordinateSystem.SPACE_BASED;
range0.toString(range_CoordinateSystem2);
Range range6 = Range.of(9223372036854775382L);
range4.endsBefore(range6);
Range.CoordinateSystem range_CoordinateSystem3 = Range.CoordinateSystem.ZERO_BASED;
Range.parseRange("[ 4137 .. 4137 ]/0B", range_CoordinateSystem3);
range3.intersects(range4);
range4.intersects(range5);
Range.parseRange("[ 4137 .. 4137 ]/0B");
Range.CoordinateSystem range_CoordinateSystem4 = Range.CoordinateSystem.ZERO_BASED;
Range.Builder range_Builder0 = null;
try {
range_Builder0 = new Range.Builder(range_CoordinateSystem4, 9223372036854775382L, 255L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 20
/*Coverage entropy=3.525538953174971
*/
@Test(timeout = 4000)
public void test20() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-469L), 65535L);
Range range0 = Range.of(0L, 1871L);
long long0 = 1L;
Range range1 = Range.ofLength(0L);
range1.complement(range0);
range0.split(3262L);
long long1 = (-1530L);
Range range2 = Range.of((-1530L), 4294967295L);
range0.intersection(range1);
range0.complement(range2);
Range.Comparators.values();
// Undeclared exception!
try {
Range.CoordinateSystem.valueOf("xvK_5G$TzOc=");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.CoordinateSystem.xvK_5G$TzOc=
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 21
/*Coverage entropy=3.3726910395289234
*/
@Test(timeout = 4000)
public void test21() throws Throwable {
Long long0 = new Long(1350L);
Range range0 = Range.of((-2407L), 1350L);
range0.equals(long0);
range0.getBegin();
range0.isEmpty();
Range range1 = Range.of(1L);
range1.intersects(range0);
Range range2 = Range.of((-1960L));
range2.endsBefore(range1);
range1.isEmpty();
// Undeclared exception!
try {
Range.ofLength((-1960L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// must be >=0
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 22
/*Coverage entropy=3.35383896813415
*/
@Test(timeout = 4000)
public void test22() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-469L), (-469L));
Range.Builder range_Builder1 = range_Builder0.shift(0L);
Range range0 = Range.of((-469L), 0L);
Range.Builder range_Builder2 = range_Builder1.copy();
Range.Builder range_Builder3 = range_Builder1.shift(0L);
Consumer<Object> consumer0 = (Consumer<Object>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
range0.equals(range_Builder1);
range0.equals(range_Builder3);
Range.Builder range_Builder4 = new Range.Builder(range_Builder3);
range_Builder2.shift(65535L);
Range.of((-3266L), 285L);
Range.of((-2757L));
range_Builder3.expandBegin((-224L));
// Undeclared exception!
try {
range_Builder1.build();
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 23
/*Coverage entropy=3.14716708893603
*/
@Test(timeout = 4000)
public void test23() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-145L), 127L);
Range.Builder range_Builder1 = range_Builder0.shift((-3786L));
Range.Builder range_Builder2 = range_Builder1.shift(0L);
range_Builder1.expandBegin((-3786L));
long long0 = 3385L;
range_Builder1.expandEnd(3385L);
range_Builder0.expandBegin((-458L));
long long1 = 4294967295L;
Range range0 = Range.of(4294967295L);
Object object0 = new Object();
range0.equals(range_Builder2);
Range.Builder range_Builder3 = new Range.Builder();
range_Builder0.shift((-958L));
// Undeclared exception!
try {
Range.of((-5L), (-1601L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 24
/*Coverage entropy=3.1383756702533585
*/
@Test(timeout = 4000)
public void test24() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
long long0 = (-145L);
long long1 = 127L;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-145L), 127L);
Range.Builder range_Builder1 = new Range.Builder();
Range.Builder range_Builder2 = new Range.Builder(127L, 127L);
long long2 = 3696L;
Range range0 = Range.of(3696L);
range0.equals(range_Builder0);
range0.equals(range_Builder0);
Range.Builder range_Builder3 = new Range.Builder(range_Builder2);
range_Builder0.shift((-145L));
// Undeclared exception!
try {
Range.of(9223372036854775553L, (-32767L));
fail("Expecting exception: IndexOutOfBoundsException");
} catch(IndexOutOfBoundsException e) {
//
// given length -32767 would make range [9223372036854775553 - ? ] beyond max allowed end offset
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 25
/*Coverage entropy=3.2224106775160113
*/
@Test(timeout = 4000)
public void test25() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(1L, 1L);
long long0 = (-1L);
Range.Builder range_Builder1 = range_Builder0.expandEnd((-1L));
range_Builder0.expandBegin(65535L);
Range.Builder range_Builder2 = range_Builder0.expandEnd((-2744L));
range_Builder0.expandBegin((-2744L));
Range range0 = Range.of(1L);
Object object0 = new Object();
range0.equals(object0);
Range.Builder range_Builder3 = new Range.Builder(range_Builder1);
range_Builder2.expandBegin((-1L));
long long1 = 574L;
range_Builder2.shift(574L);
// Undeclared exception!
try {
Range.of(275L, 1L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 26
/*Coverage entropy=3.1909295529466593
*/
@Test(timeout = 4000)
public void test26() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
long long0 = 131L;
long long1 = 4294967295L;
Range range0 = Range.of(131L, 4294967295L);
range0.equals(range_CoordinateSystem0);
Range range1 = Range.of(131L);
long long2 = 0L;
Range range2 = Range.of(0L);
range1.equals(range2);
long long3 = (-9223372036854775808L);
Range.Builder range_Builder0 = null;
try {
range_Builder0 = new Range.Builder((-9223372036854775808L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// must be >=0
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 27
/*Coverage entropy=3.3968646828021054
*/
@Test(timeout = 4000)
public void test27() throws Throwable {
Range range0 = Range.of(4135L);
Range.Builder range_Builder0 = new Range.Builder();
Range.Builder range_Builder1 = range_Builder0.expandEnd(2045L);
Range.Builder range_Builder2 = range_Builder1.expandEnd(2045L);
range_Builder2.expandBegin((-1L));
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range1 = Range.of(range_CoordinateSystem0, 2045L, 9223372036854775807L);
Range range2 = Range.ofLength(1525L);
range1.intersects(range0);
Range.Builder range_Builder3 = range_Builder0.shift((-559L));
range2.endsBefore(range0);
range2.intersects(range0);
range2.intersects(range1);
// Undeclared exception!
try {
range_Builder3.contractBegin(9223372036854775807L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 28
/*Coverage entropy=3.6328135032465343
*/
@Test(timeout = 4000)
public void test28() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder();
range_Builder0.shift(128L);
Range range0 = Range.of((-1499L), 128L);
Range.Builder range_Builder1 = range_Builder0.copy();
long long0 = 1L;
Range range1 = Range.ofLength(128L);
range1.complement(range0);
long long1 = 9223372036854774457L;
range1.split(9223372036854774457L);
Range.of(0L, 1L);
// Undeclared exception!
try {
range_Builder1.contractBegin(128L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 29
/*Coverage entropy=3.531582973352248
*/
@Test(timeout = 4000)
public void test29() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
long long0 = 127L;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-145L), 127L);
range_Builder0.shift((-3786L));
Range.Builder range_Builder1 = range_Builder0.copy();
Range.Builder range_Builder2 = range_Builder0.expandBegin((-4294967628L));
Range range0 = Range.of((-4294967628L));
range0.equals(range_Builder1);
range0.equals(range_Builder2);
long long1 = 255L;
Range range1 = Range.of((-145L), 255L);
Range range2 = range0.intersection(range1);
range2.complement(range1);
Range.Comparators.values();
// Undeclared exception!
try {
Range.CoordinateSystem.valueOf("");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.CoordinateSystem.
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 30
/*Coverage entropy=3.2079600775434685
*/
@Test(timeout = 4000)
public void test30() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder((-3610L), (-3610L));
long long0 = 1276L;
Range.Builder range_Builder1 = new Range.Builder(1276L, 1276L);
Range.Builder range_Builder2 = new Range.Builder();
Range.Builder range_Builder3 = range_Builder2.expandEnd(198L);
range_Builder3.expandEnd((-3610L));
Range.Builder range_Builder4 = range_Builder1.expandBegin((-4L));
Range range0 = Range.of((-1L));
range0.equals(range_Builder4);
// Undeclared exception!
try {
Range.of(4122L, (-4L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 31
/*Coverage entropy=3.0615135024203357
*/
@Test(timeout = 4000)
public void test31() throws Throwable {
Range range0 = Range.of(9223372036854775807L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range range1 = Range.ofLength(65535L);
range1.endsBefore(range0);
long long0 = (-770L);
// Undeclared exception!
try {
Range.of(65535L, 102L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 32
/*Coverage entropy=3.193159742024955
*/
@Test(timeout = 4000)
public void test32() throws Throwable {
Range.of(255L, 255L);
Range.Builder range_Builder0 = new Range.Builder();
Range range0 = Range.of(2422L);
assertFalse(range0.isEmpty());
}
/**
//Test case number: 33
/*Coverage entropy=3.613198952184682
*/
@Test(timeout = 4000)
public void test33() throws Throwable {
long long0 = 4138L;
Range range0 = Range.of(4138L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(255L, 255L);
range0.isSubRangeOf(range1);
Range range2 = Range.of(range_CoordinateSystem0, 4138L, 4138L);
range2.intersection(range0);
range2.isEmpty();
range2.toString();
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.RESIDUE_BASED;
Range range3 = Range.of(range_CoordinateSystem1, 4138L, 4138L);
Range.of((-2013L), 4138L);
Range.CoordinateSystem range_CoordinateSystem2 = Range.CoordinateSystem.SPACE_BASED;
range0.toString(range_CoordinateSystem2);
Range range4 = Range.of(9223372036854775382L);
range3.endsBefore(range4);
// Undeclared exception!
try {
Range.ofLength((-32768L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// must be >=0
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 34
/*Coverage entropy=3.5492927790121063
*/
@Test(timeout = 4000)
public void test34() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(575L);
Range.Builder range_Builder1 = new Range.Builder((-1L), 575L);
Range range0 = Range.of((-1L), 7L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.Builder range_Builder2 = new Range.Builder(range0);
Range.Builder range_Builder3 = new Range.Builder(range0);
range_Builder0.expandEnd((-74L));
range_Builder2.contractEnd((-74L));
Range.ofLength(1864L);
range_Builder0.expandEnd((-74L));
Range.Builder range_Builder4 = range_Builder2.expandBegin((-2147483648L));
Range range1 = Range.of((-2147483648L));
range1.equals("r9+JZF~|pf=hSSC/ ");
Range.Builder range_Builder5 = new Range.Builder(range_Builder1);
Range.Builder range_Builder6 = range_Builder4.shift(2355L);
Range.of(201L, 1626L);
// Undeclared exception!
try {
range_Builder6.contractBegin(3112L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 35
/*Coverage entropy=3.2640212704669778
*/
@Test(timeout = 4000)
public void test35() throws Throwable {
Range range0 = Range.of(4294967295L, 4294967295L);
Range range1 = Range.of(1034L);
Consumer<Long> consumer0 = (Consumer<Long>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
assertFalse(range0.equals((Object)range1));
}
/**
//Test case number: 36
/*Coverage entropy=3.6181895546700438
*/
@Test(timeout = 4000)
public void test36() throws Throwable {
Range range0 = Range.of(4L, 4L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
range_CoordinateSystem0.toString();
Range range1 = Range.ofLength(4L);
long long0 = (-770L);
Range range2 = Range.of((-770L), (-770L));
range1.isSubRangeOf(range0);
Range range3 = Range.of((-770L));
Range.of(426L, 426L);
range2.endsBefore(range3);
range0.intersection(range1);
// Undeclared exception!
try {
Range.parseRange("Space Based");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// can not parse Space Based into a Range
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 37
/*Coverage entropy=3.031514648030985
*/
@Test(timeout = 4000)
public void test37() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder((-2407L), 1L);
range_Builder0.expandEnd((-1L));
range_Builder0.expandEnd((-1485L));
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 1243L, 4294967287L);
Range.Builder range_Builder1 = new Range.Builder(range0);
Range.Builder range_Builder2 = new Range.Builder(range_Builder1);
assertFalse(range_Builder2.equals((Object)range_Builder0));
}
/**
//Test case number: 38
/*Coverage entropy=3.0593548485908344
*/
@Test(timeout = 4000)
public void test38() throws Throwable {
long long0 = 575L;
Range.Builder range_Builder0 = new Range.Builder(575L);
Range.Builder range_Builder1 = new Range.Builder((-1L), 575L);
Range range0 = Range.of((-1L), 7L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
range0.getBegin(range_CoordinateSystem0);
// Undeclared exception!
try {
Range.ofLength((-1L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// must be >=0
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 39
/*Coverage entropy=3.5009793135434797
*/
@Test(timeout = 4000)
public void test39() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(575L);
Range.Builder range_Builder1 = new Range.Builder((-1L), 575L);
Range range0 = Range.of((-1L), 7L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.Builder range_Builder2 = new Range.Builder(range0);
Range.Builder range_Builder3 = new Range.Builder(range0);
long long0 = (-74L);
range_Builder2.contractEnd((-74L));
Range.ofLength(1864L);
range_Builder0.expandEnd((-74L));
long long1 = 275L;
long long2 = (-2147483648L);
range_Builder2.expandBegin((-2147483648L));
Range.of((-2147483648L));
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range.Builder range_Builder4 = null;
try {
range_Builder4 = new Range.Builder(range_CoordinateSystem0, 1864L, (-2147483648L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 40
/*Coverage entropy=3.6345645808480893
*/
@Test(timeout = 4000)
public void test40() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder((-1L), 575L);
Range range0 = Range.ofLength(575L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
range_Builder0.contractBegin((-1L));
Range.Builder range_Builder1 = range_Builder0.contractEnd(575L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
range0.getBegin(range_CoordinateSystem0);
Range range1 = Range.ofLength(1782L);
Range.Builder range_Builder2 = range_Builder1.expandBegin(1782L);
range_Builder2.expandBegin(1782L);
range_Builder2.expandBegin((-984L));
range0.isSubRangeOf(range1);
range_Builder2.shift(1782L);
Range range2 = Range.of(range_CoordinateSystem0, (-1L), 2147483647L);
range0.endsBefore(range2);
Range.ofLength(255L);
Range range3 = Range.of((-1L));
range1.endsBefore(range1);
Range.of((-111L), 2590L);
Range range4 = Range.of((-8L));
Range.Comparators.values();
range3.startsBefore(range4);
Range.Builder range_Builder3 = null;
try {
range_Builder3 = new Range.Builder(9223372036854775807L, 0L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 41
/*Coverage entropy=3.3288772833852036
*/
@Test(timeout = 4000)
public void test41() throws Throwable {
long long0 = 575L;
Range.Builder range_Builder0 = new Range.Builder(575L);
Range.Builder range_Builder1 = new Range.Builder((-1L), 575L);
long long1 = 7L;
Range range0 = Range.of((-1L), 7L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.Builder range_Builder2 = new Range.Builder(range0);
Range.Builder range_Builder3 = new Range.Builder(range0);
long long2 = (-74L);
range_Builder2.contractEnd((-74L));
Range range1 = Range.ofLength(1864L);
range0.isSubRangeOf(range1);
// Undeclared exception!
try {
Range.of(1864L, 7L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 42
/*Coverage entropy=3.1516338938412907
*/
@Test(timeout = 4000)
public void test42() throws Throwable {
Range.of((-5L));
Range.of((-5L));
Range.of(9223372036854775807L);
Range.Builder range_Builder0 = new Range.Builder();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
// Undeclared exception!
try {
Range.of(range_CoordinateSystem0, 9223372036854775807L, (-5L));
fail("Expecting exception: IndexOutOfBoundsException");
} catch(IndexOutOfBoundsException e) {
//
// given length -5 would make range [9223372036854775807 - ? ] beyond max allowed end offset
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 43
/*Coverage entropy=3.3776583607544146
*/
@Test(timeout = 4000)
public void test43() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(575L);
Range range0 = Range.ofLength(575L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.Builder range_Builder1 = new Range.Builder(range0);
Range.Builder range_Builder2 = new Range.Builder(range0);
range_Builder0.contractEnd(575L);
Range range1 = Range.ofLength(1782L);
range1.intersects(range1);
Range.of(1002L, 4294967298L);
range_Builder0.expandBegin(4294967298L);
Range.of(575L);
range_Builder1.expandBegin(1782L);
assertNotSame(range0, range1);
}
/**
//Test case number: 44
/*Coverage entropy=3.475273007145659
*/
@Test(timeout = 4000)
public void test44() throws Throwable {
long long0 = 4138L;
Range range0 = Range.of(4138L);
Range range1 = Range.of(255L, 255L);
range0.isSubRangeOf(range1);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range2 = Range.of(range_CoordinateSystem0, 4138L, 4138L);
Range.of((-2033L), 4138L);
Range range3 = Range.of((-2033L), (-2033L));
range2.endsBefore(range3);
Range.of(9223372036854775194L);
Range.Comparators.values();
Range.Builder range_Builder0 = null;
try {
range_Builder0 = new Range.Builder(9223372036854775807L, 255L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 45
/*Coverage entropy=3.638981967324429
*/
@Test(timeout = 4000)
public void test45() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(78L, 65535L);
range_Builder0.copy();
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
long long0 = 1351L;
Range range0 = Range.of(range_CoordinateSystem0, 78L, 1351L);
Object[] objectArray0 = new Object[7];
objectArray0[0] = (Object) range_CoordinateSystem0;
objectArray0[1] = (Object) range0;
objectArray0[2] = (Object) range_Builder0;
Object object0 = new Object();
objectArray0[3] = object0;
objectArray0[4] = (Object) range0;
objectArray0[5] = (Object) range_Builder0;
objectArray0[6] = (Object) linkedList0;
linkedList0.toArray(objectArray0);
linkedList0.addFirst(range0);
List<Range> list0 = range0.complementFrom(linkedList0);
LinkedList<Range> linkedList1 = new LinkedList<Range>(list0);
Range range1 = Range.of(1351L);
Consumer<Object> consumer0 = (Consumer<Object>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range1.forEach(consumer0);
range0.intersection(range1);
Range.Comparators.values();
// Undeclared exception!
try {
Range.CoordinateSystem.valueOf("efjN`adN-o");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.CoordinateSystem.efjN`adN-o
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 46
/*Coverage entropy=3.4416071545659537
*/
@Test(timeout = 4000)
public void test46() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder((-3610L), (-3610L));
long long0 = (-1L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range.Builder range_Builder1 = new Range.Builder(range_CoordinateSystem0, 1871L, 1871L);
Range.Builder range_Builder2 = range_Builder1.shift((-1L));
range_Builder1.build();
range_Builder1.copy();
range_Builder0.expandBegin(1837L);
Range.of((-32768L));
range_Builder2.contractBegin((-32768L));
Range.of(65535L);
// Undeclared exception!
try {
Range.of(32767L, (-3786L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 47
/*Coverage entropy=3.3019088753047665
*/
@Test(timeout = 4000)
public void test47() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-145L), 127L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Object[] objectArray0 = new Object[9];
objectArray0[0] = (Object) linkedList0;
objectArray0[1] = (Object) linkedList0;
objectArray0[2] = (Object) range_Builder0;
Object object0 = new Object();
objectArray0[3] = object0;
Object object1 = new Object();
objectArray0[4] = object1;
objectArray0[5] = (Object) range_CoordinateSystem0;
objectArray0[6] = (Object) range_Builder0;
Object object2 = new Object();
objectArray0[7] = object2;
objectArray0[8] = (Object) range_CoordinateSystem0;
linkedList0.toArray(objectArray0);
Range range0 = Range.of((-3786L), (-800L));
linkedList0.addFirst(range0);
List<Range> list0 = range0.complementFrom(linkedList0);
LinkedList<Range> linkedList1 = new LinkedList<Range>(list0);
LinkedList<Range> linkedList2 = new LinkedList<Range>();
Range.Builder range_Builder1 = range_Builder0.shift(127L);
Range.of((-104L), 1869L);
Range.of((-238L), 1854L);
Range.Builder range_Builder2 = range_Builder1.expandBegin(691L);
assertSame(range_Builder0, range_Builder2);
}
/**
//Test case number: 48
/*Coverage entropy=3.4700567066286254
*/
@Test(timeout = 4000)
public void test48() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder((-2407L), 1L);
range_Builder0.expandEnd((-1L));
Range.Builder range_Builder1 = range_Builder0.expandEnd((-1485L));
Range.Builder range_Builder2 = range_Builder0.expandBegin(275L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range0 = Range.of(range_CoordinateSystem0, (-559L), 1L);
Range range1 = Range.ofLength(1172L);
range0.intersects(range1);
range0.iterator();
range_Builder1.shift((-630L));
range0.endsBefore(range1);
range1.intersects(range0);
boolean boolean0 = range0.intersects(range1);
// // Unstable assertion: assertTrue(boolean0);
range_Builder2.expandBegin((-559L));
Range range2 = range0.intersection(range1);
// // Unstable assertion: assertTrue(range2.isEmpty());
}
/**
//Test case number: 49
/*Coverage entropy=3.172269617069339
*/
@Test(timeout = 4000)
public void test49() throws Throwable {
long long0 = (-2749L);
Range range0 = Range.of((-2749L));
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
range0.getEnd(range_CoordinateSystem0);
Range range1 = Range.of((-2749L), (-2749L));
range1.isSubRangeOf(range0);
Range.Builder range_Builder0 = null;
try {
range_Builder0 = new Range.Builder((-2749L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// must be >=0
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 50
/*Coverage entropy=3.3170854239925207
*/
@Test(timeout = 4000)
public void test50() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder((-42L), (-42L));
Range.Builder range_Builder1 = new Range.Builder();
Range range0 = Range.of((-145L), 198L);
range_Builder0.expandEnd(127L);
Range.Builder range_Builder2 = new Range.Builder(255L);
range_Builder2.expandBegin((-1L));
Range.of((-42L));
range0.equals(range_Builder1);
Range.Builder range_Builder3 = new Range.Builder(range_Builder1);
range_Builder3.shift(1276L);
// Undeclared exception!
try {
Range.of(1849L, (-5069L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 51
/*Coverage entropy=3.314260057909176
*/
@Test(timeout = 4000)
public void test51() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder((-3610L), (-3610L));
Range.Builder range_Builder1 = range_Builder0.expandEnd((-1L));
range_Builder0.copy();
range_Builder1.expandEnd((-128L));
Range.Builder range_Builder2 = new Range.Builder((-128L), (-128L));
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 366L, 1145L);
Range range1 = Range.ofLength(32767L);
range1.intersects(range0);
range_Builder2.shift(366L);
range1.endsBefore(range0);
range0.getLength();
// Undeclared exception!
try {
Range.ofLength((-1485L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// must be >=0
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 52
/*Coverage entropy=3.6534291619614656
*/
@Test(timeout = 4000)
public void test52() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-145L), 127L);
Range.Builder range_Builder1 = range_Builder0.shift((-3786L));
Range range0 = Range.of(3L, 1871L);
Range.Builder range_Builder2 = range_Builder0.copy();
Range.Builder range_Builder3 = range_Builder1.shift(1768L);
Range range1 = range_Builder2.build();
Consumer<Object> consumer0 = (Consumer<Object>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
Range range2 = range0.intersection(range1);
Range range3 = Range.of((-469L));
range0.startsBefore(range3);
Range.Builder range_Builder4 = new Range.Builder();
range0.intersects(range1);
range2.isEmpty();
Range.of(127L);
Range.Builder range_Builder5 = range_Builder0.expandBegin((-1L));
assertSame(range_Builder5, range_Builder3);
}
/**
//Test case number: 53
/*Coverage entropy=3.184783964830172
*/
@Test(timeout = 4000)
public void test53() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, (-422L), (-422L));
range0.getLength();
range0.iterator();
Range range1 = Range.of(range_CoordinateSystem0, (-422L), (-422L));
range0.complement(range1);
Range.Comparators.values();
range1.intersection(range0);
range1.endsBefore(range0);
long long0 = (-1083L);
range1.endsBefore(range0);
range0.getLength();
// Undeclared exception!
try {
Range.ofLength((-1083L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// must be >=0
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 54
/*Coverage entropy=3.414302138049348
*/
@Test(timeout = 4000)
public void test54() throws Throwable {
Range range0 = Range.ofLength(0L);
Range.Builder range_Builder0 = new Range.Builder(9L, 9223372036854775807L);
long long0 = (-1L);
range_Builder0.expandEnd(9L);
Range.Builder range_Builder1 = range_Builder0.expandBegin(9223372036854775807L);
Range range1 = Range.ofLength(9L);
range0.equals(range_Builder1);
Range.of(1855L);
Range.of(0L, 1866L);
Range range2 = Range.ofLength(0L);
range2.intersection(range1);
Range.Comparators.values();
// Undeclared exception!
try {
Range.CoordinateSystem.valueOf("kOxP;{hv)QThGiXU");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.CoordinateSystem.kOxP;{hv)QThGiXU
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 55
/*Coverage entropy=3.5499997290764718
*/
@Test(timeout = 4000)
public void test55() throws Throwable {
long long0 = 0L;
Range range0 = Range.of(0L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range range1 = Range.ofLength(0L);
range0.endsBefore(range1);
long long1 = (-770L);
Range range2 = Range.of((-770L), (-770L));
range0.startsBefore(range1);
Object object0 = new Object();
range0.equals(object0);
Range range3 = Range.of((-770L));
Object object1 = new Object();
range3.equals(object1);
long long2 = (-1L);
range2.asRange();
long long3 = (-915L);
Range.Builder range_Builder0 = null;
try {
range_Builder0 = new Range.Builder((-1L), (-915L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 56
/*Coverage entropy=3.6014952855418523
*/
@Test(timeout = 4000)
public void test56() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-469L), 1871L);
Range.Builder range_Builder1 = new Range.Builder();
Range range0 = Range.of((-469L), 0L);
range_Builder1.copy();
Range range1 = Range.ofLength(1L);
range0.complement(range1);
range0.split(1L);
long long0 = 4294967295L;
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Object[] objectArray0 = new Object[0];
linkedList0.toArray(objectArray0);
LinkedList<Range> linkedList1 = new LinkedList<Range>();
linkedList1.addFirst(range1);
range0.complementFrom(linkedList1);
LinkedList<Range> linkedList2 = new LinkedList<Range>(linkedList1);
LinkedList<Range> linkedList3 = new LinkedList<Range>();
Range.Builder range_Builder2 = new Range.Builder(1L, 3095L);
range_Builder2.shift(0L);
// Undeclared exception!
try {
Range.of(1871L, 1868L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 57
/*Coverage entropy=3.1566783114691677
*/
@Test(timeout = 4000)
public void test57() throws Throwable {
Range range0 = Range.ofLength(0L);
Long long0 = new Long(0L);
range0.equals(long0);
range0.getBegin();
boolean boolean0 = range0.isEmpty();
assertTrue(boolean0);
Range range1 = Range.of(0L);
range0.intersects(range1);
boolean boolean1 = range1.endsBefore(range0);
boolean boolean2 = range0.intersects(range1);
assertTrue(boolean2 == boolean1);
Range range2 = Range.ofLength(0L);
assertFalse(range2.equals((Object)range1));
}
/**
//Test case number: 58
/*Coverage entropy=3.3270346505178816
*/
@Test(timeout = 4000)
public void test58() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder((-1L), 575L);
Range.Builder range_Builder1 = range_Builder0.expandEnd((-1L));
Range.Builder range_Builder2 = range_Builder0.expandEnd(4294967295L);
range_Builder1.expandBegin(275L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range0 = Range.of((-1L));
Consumer<Long> consumer0 = (Consumer<Long>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
range0.equals(range_CoordinateSystem0);
range_Builder2.shift((-1485L));
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.RESIDUE_BASED;
range0.getEnd(range_CoordinateSystem1);
Range.CoordinateSystem range_CoordinateSystem2 = Range.CoordinateSystem.SPACE_BASED;
// Undeclared exception!
try {
Range.parseRange("bK", range_CoordinateSystem2);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// can not parse bK into a Range
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 59
/*Coverage entropy=3.402850173856357
*/
@Test(timeout = 4000)
public void test59() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-145L), 127L);
Range.Builder range_Builder1 = new Range.Builder();
Range.Builder range_Builder2 = new Range.Builder(127L, 127L);
long long0 = 3696L;
range_Builder2.expandBegin(282L);
Range range0 = Range.of(3696L);
Consumer<Long> consumer0 = (Consumer<Long>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
range0.equals(range_Builder0);
range_Builder1.contractBegin((-145L));
Range.of(0L);
// Undeclared exception!
try {
Range.of(65535L, 32767L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 60
/*Coverage entropy=3.401800865227197
*/
@Test(timeout = 4000)
public void test60() throws Throwable {
Range range0 = Range.of(0L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range range1 = Range.ofLength(0L);
range0.endsBefore(range1);
Range range2 = Range.of(0L, 0L);
range0.startsBefore(range1);
Range range3 = range2.intersection(range0);
Range range4 = Range.of(0L);
range3.startsBefore(range2);
Range.Builder range_Builder0 = new Range.Builder();
range4.intersects(range3);
range3.isEmpty();
Range.of(0L);
Range range5 = Range.ofLength(0L);
// Undeclared exception!
try {
range5.split(0L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// max splitLength must be >= 1
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 61
/*Coverage entropy=3.6531138041409847
*/
@Test(timeout = 4000)
public void test61() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-145L), 127L);
Range.Builder range_Builder1 = range_Builder0.shift((-3786L));
Range range0 = Range.of(3L, 1871L);
Range.Builder range_Builder2 = range_Builder0.copy();
range_Builder1.shift(1768L);
Range range1 = range_Builder2.build();
Consumer<Object> consumer0 = (Consumer<Object>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
range0.intersection(range1);
Range.of((-469L));
Range.of((-32768L), (-1984L));
Range.of(1872L);
Range.Builder range_Builder3 = range_Builder1.expandBegin((-1984L));
assertSame(range_Builder1, range_Builder3);
}
/**
//Test case number: 62
/*Coverage entropy=3.6112283700640226
*/
@Test(timeout = 4000)
public void test62() throws Throwable {
Range range0 = Range.of(0L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range range1 = Range.ofLength(0L);
range0.endsBefore(range1);
Range range2 = Range.of((-770L), (-770L));
range0.startsBefore(range1);
range2.intersection(range0);
Range range3 = Range.of((-770L));
range3.startsBefore(range0);
Range.Builder range_Builder0 = new Range.Builder();
range0.intersects(range2);
range2.isEmpty();
Range.of((-19L));
// Undeclared exception!
try {
range2.split((-19L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// max splitLength must be >= 1
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 63
/*Coverage entropy=3.2480453545970223
*/
@Test(timeout = 4000)
public void test63() throws Throwable {
Range range0 = Range.of((-5L));
Range.of((-5L));
Range range1 = Range.of(9223372036854775807L, 9223372036854775807L);
range1.startsBefore(range0);
// Undeclared exception!
try {
range1.intersection(range0);
fail("Expecting exception: IndexOutOfBoundsException");
} catch(IndexOutOfBoundsException e) {
//
// given length -5 would make range [9223372036854775807 - ? ] beyond max allowed end offset
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 64
/*Coverage entropy=3.612532505383268
*/
@Test(timeout = 4000)
public void test64() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(78L, 65535L);
range_Builder0.copy();
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 78L, 1351L);
Object[] objectArray0 = new Object[7];
objectArray0[0] = (Object) range_CoordinateSystem0;
objectArray0[1] = (Object) range0;
objectArray0[2] = (Object) range_Builder0;
Object object0 = new Object();
objectArray0[3] = object0;
objectArray0[4] = (Object) range0;
objectArray0[5] = (Object) range_Builder0;
objectArray0[6] = (Object) linkedList0;
linkedList0.toArray(objectArray0);
linkedList0.addFirst(range0);
List<Range> list0 = range0.complementFrom(linkedList0);
LinkedList<Range> linkedList1 = new LinkedList<Range>(list0);
LinkedList<Range> linkedList2 = new LinkedList<Range>();
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.ZERO_BASED;
Range range1 = Range.of(range_CoordinateSystem1, 255L, 254L);
Range.ofLength(255L);
range1.getEnd(range_CoordinateSystem0);
Range range2 = Range.of(366L, 650L);
range0.intersects(range2);
range_Builder0.shift(572L);
range2.endsBefore(range1);
Range.CoordinateSystem range_CoordinateSystem2 = Range.CoordinateSystem.ZERO_BASED;
// Undeclared exception!
try {
Range.parseRange("can not parse ", range_CoordinateSystem2);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// can not parse can not parse into a Range
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 65
/*Coverage entropy=3.5807488817401363
*/
@Test(timeout = 4000)
public void test65() throws Throwable {
long long0 = 78L;
long long1 = 65535L;
Range.Builder range_Builder0 = new Range.Builder(78L, 65535L);
range_Builder0.copy();
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
long long2 = 1351L;
Range range0 = Range.of(range_CoordinateSystem0, 78L, 1351L);
linkedList0.pollFirst();
Object[] objectArray0 = new Object[7];
objectArray0[0] = (Object) range_CoordinateSystem0;
objectArray0[1] = (Object) range0;
objectArray0[2] = (Object) range_Builder0;
range_Builder0.contractBegin(78L);
long long3 = 2147483647L;
Range range1 = Range.of(2147483647L);
Range range2 = Range.of((-1290L), 2147483647L);
range2.complement(range1);
// Undeclared exception!
try {
range2.intersection((Range) null);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// Null Range used in intersection operation.
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 66
/*Coverage entropy=3.3081015535348004
*/
@Test(timeout = 4000)
public void test66() throws Throwable {
Range.of(104L, 4294967295L);
Range.of(131L);
Range.of(131L, 131L);
Range.Builder range_Builder0 = new Range.Builder(4294967295L, 4294967295L);
Range.Builder range_Builder1 = new Range.Builder(range_Builder0);
Range.Builder range_Builder2 = range_Builder1.expandEnd(104L);
Range.Builder range_Builder3 = new Range.Builder(range_Builder2);
// Undeclared exception!
try {
range_Builder3.contractBegin(4294967295L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 67
/*Coverage entropy=3.2362437609902015
*/
@Test(timeout = 4000)
public void test67() throws Throwable {
Range.of(104L, 4294967295L);
long long0 = 131L;
Range.of(131L, 131L);
Range.Builder range_Builder0 = new Range.Builder(4294967295L, 4294967295L);
Range.Builder range_Builder1 = new Range.Builder(range_Builder0);
range_Builder1.contractEnd((-1757L));
Range.Builder range_Builder2 = range_Builder1.expandEnd(104L);
Range.Builder range_Builder3 = new Range.Builder(range_Builder2);
// Undeclared exception!
try {
range_Builder3.contractBegin(4294967295L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 68
/*Coverage entropy=3.2762058352396584
*/
@Test(timeout = 4000)
public void test68() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(575L);
Range range0 = Range.ofLength(575L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.Builder range_Builder1 = new Range.Builder(range0);
Range.Builder range_Builder2 = new Range.Builder(range0);
Range.Builder range_Builder3 = range_Builder0.contractEnd(575L);
Range range1 = Range.ofLength(1754L);
range0.isSubRangeOf(range1);
Range range2 = Range.of(1002L, 4294967303L);
range2.intersects(range1);
range1.intersects(range0);
Range.Builder range_Builder4 = new Range.Builder(1754L);
range_Builder3.expandBegin((-369L));
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
// Undeclared exception!
try {
Range.parseRange((String) null, range_CoordinateSystem0);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// no message in exception (getMessage() returned null)
//
}
}
/**
//Test case number: 69
/*Coverage entropy=2.818411947497937
*/
@Test(timeout = 4000)
public void test69() throws Throwable {
Range range0 = Range.ofLength(0L);
Long long0 = new Long(0L);
boolean boolean0 = range0.equals(long0);
long long1 = range0.getBegin();
assertEquals(0L, long1);
boolean boolean1 = range0.isEmpty();
Range range1 = Range.ofLength(0L);
boolean boolean2 = range0.intersects(range1);
assertFalse(boolean2 == boolean1);
boolean boolean3 = range1.endsBefore(range0);
assertFalse(boolean3 == boolean0);
Range range2 = Range.ofLength(0L);
assertSame(range2, range0);
}
/**
//Test case number: 70
/*Coverage entropy=3.309253284724307
*/
@Test(timeout = 4000)
public void test70() throws Throwable {
Range range0 = Range.of(99L, 4294967328L);
Range.of(131L);
Range.Builder range_Builder0 = new Range.Builder(2421L);
Range.Builder range_Builder1 = new Range.Builder(1998L, 2421L);
Range.Builder range_Builder2 = new Range.Builder(range_Builder0);
Range.Builder range_Builder3 = new Range.Builder(range0);
range_Builder3.contractBegin(131L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
assertFalse(linkedList0.contains(range0));
}
/**
//Test case number: 71
/*Coverage entropy=3.588399698874494
*/
@Test(timeout = 4000)
public void test71() throws Throwable {
long long0 = 4138L;
Range range0 = Range.of(4138L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(255L, 255L);
range0.isSubRangeOf(range1);
Range range2 = Range.of(range_CoordinateSystem0, 4138L, 4138L);
range2.intersection(range0);
range2.isEmpty();
range2.toString();
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.RESIDUE_BASED;
Range range3 = Range.of(range_CoordinateSystem1, 4138L, 4138L);
Range.of((-2013L), 4138L);
Range range4 = Range.of(9223372036854775382L);
range3.endsBefore(range4);
Range.of(9223372036854775194L);
long long1 = 9223372036854775807L;
Range.Comparators.values();
Range.Builder range_Builder0 = null;
try {
range_Builder0 = new Range.Builder(9223372036854775807L, (-1L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 72
/*Coverage entropy=3.657564395515379
*/
@Test(timeout = 4000)
public void test72() throws Throwable {
Range range0 = Range.of(0L, 0L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range range1 = Range.ofLength(0L);
Range range2 = Range.of((-770L), (-770L));
boolean boolean0 = range1.isSubRangeOf(range0);
Range range3 = Range.of((-770L));
Range range4 = Range.of(426L, 426L);
boolean boolean1 = range2.endsBefore(range3);
assertFalse(boolean1);
Range range5 = range0.intersection(range1);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range6 = Range.of(range_CoordinateSystem0, 0L, 0L);
assertFalse(range6.isEmpty());
boolean boolean2 = range5.endsBefore(range2);
assertFalse(boolean2 == boolean0);
Range range7 = Range.of((-770L));
range4.intersects(range1);
range7.isEmpty();
assertSame(range7, range2);
Range range8 = Range.ofLength(0L);
assertSame(range8, range5);
assertTrue(range8.isEmpty());
}
/**
//Test case number: 73
/*Coverage entropy=2.9190235060608334
*/
@Test(timeout = 4000)
public void test73() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range0 = Range.of(range_CoordinateSystem0, (-1111L), (-1111L));
long long0 = range0.getEnd();
assertEquals((-1111L), long0);
}
/**
//Test case number: 74
/*Coverage entropy=3.2828949078742733
*/
@Test(timeout = 4000)
public void test74() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder((-1L), 575L);
Range range0 = Range.ofLength(575L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range.Builder range_Builder1 = new Range.Builder(range0);
range_Builder0.contractBegin((-1L));
Range.Builder range_Builder2 = range_Builder0.contractEnd(575L);
Range range1 = Range.ofLength(1782L);
range_Builder2.expandBegin(1782L);
range0.isSubRangeOf(range1);
range_Builder2.shift((-1128L));
range0.endsBefore(range1);
// Undeclared exception!
try {
Range.ofLength((-1L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// must be >=0
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 75
/*Coverage entropy=0.5623351446188083
*/
@Test(timeout = 4000)
public void test75() throws Throwable {
// Undeclared exception!
try {
Range.parseRange("");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// can not parse into a Range
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 76
/*Coverage entropy=2.8866098941009533
*/
@Test(timeout = 4000)
public void test76() throws Throwable {
Range.of(9223372036854775382L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
// Undeclared exception!
try {
Range.of(range_CoordinateSystem0, (-2013L), 9223372036854775382L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 77
/*Coverage entropy=3.2308254174744957
*/
@Test(timeout = 4000)
public void test77() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(1276L, 1276L);
Range.Builder range_Builder1 = new Range.Builder();
range_Builder0.expandBegin((-4L));
range_Builder1.build();
Range range0 = Range.of((-4L), 9223372036849833996L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range.Builder range_Builder2 = new Range.Builder(range_CoordinateSystem0, (-2797L), (-46L));
Range.Builder range_Builder3 = new Range.Builder(917L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
assertFalse(linkedList0.contains(range0));
}
/**
//Test case number: 78
/*Coverage entropy=3.223530831983023
*/
@Test(timeout = 4000)
public void test78() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder((-3610L), (-3610L));
Range.Builder range_Builder1 = new Range.Builder(1276L, 1276L);
Range.Builder range_Builder2 = new Range.Builder();
Range.Builder range_Builder3 = range_Builder2.expandEnd(198L);
range_Builder2.expandEnd((-1L));
range_Builder3.expandEnd((-3610L));
long long0 = 275L;
Range.Builder range_Builder4 = range_Builder1.expandBegin((-1L));
Range.of((-1L));
Range.Builder range_Builder5 = new Range.Builder(range_Builder4);
range_Builder2.shift(198L);
// Undeclared exception!
try {
Range.of(1870L, 201L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 79
/*Coverage entropy=3.1209529939096874
*/
@Test(timeout = 4000)
public void test79() throws Throwable {
long long0 = 78L;
Range.Builder range_Builder0 = new Range.Builder(78L, 65535L);
range_Builder0.copy();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range.of(range_CoordinateSystem0, 78L, 65535L);
range_Builder0.shift(65535L);
// Undeclared exception!
try {
Range.of(99L, 3L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 80
/*Coverage entropy=3.427331158545143
*/
@Test(timeout = 4000)
public void test80() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, (-145L), 127L);
Range.Builder range_Builder1 = range_Builder0.shift((-3786L));
Range range0 = Range.of(3L, 1871L);
range_Builder1.shift((-469L));
range_Builder0.copy();
range_Builder1.shift((-5505L));
Consumer<Object> consumer0 = (Consumer<Object>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
Object object0 = new Object();
Range.of((-5505L));
// Undeclared exception!
try {
Range.Comparators.valueOf("");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.Comparators.
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 81
/*Coverage entropy=3.5758599130788604
*/
@Test(timeout = 4000)
public void test81() throws Throwable {
Range range0 = Range.of(0L, 0L);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
Range range1 = Range.ofLength(0L);
Range range2 = Range.of((-770L), (-770L));
range1.isSubRangeOf(range0);
Range range3 = Range.of((-770L));
Range.of(426L, 426L);
range2.endsBefore(range3);
range0.intersection(range1);
Range.of(0L, 3122L);
Range.of(3122L);
Range.Builder range_Builder0 = null;
try {
range_Builder0 = new Range.Builder(701L, (-1033L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 82
/*Coverage entropy=3.3108223600053153
*/
@Test(timeout = 4000)
public void test82() throws Throwable {
Range range0 = Range.ofLength(128L);
range0.split(9223372036854774457L);
Range.of((-3894L));
Range.of(1L, 128L);
Range range1 = Range.of((-878L), (-878L));
assertFalse(range1.isEmpty());
}
/**
//Test case number: 83
/*Coverage entropy=3.6400489242287724
*/
@Test(timeout = 4000)
public void test83() throws Throwable {
long long0 = (-469L);
Range range0 = Range.ofLength(135L);
Range range1 = Range.of(135L, 135L);
long long1 = 1865L;
List<Range> list0 = range1.split(4L);
range0.complementFrom(list0);
Range range2 = Range.of((-66L), 4L);
range2.complement(range0);
Range.ofLength(9223372036854773462L);
Range range3 = Range.ofLength(2048L);
range3.complement(range1);
// Undeclared exception!
try {
range3.split((-145L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// max splitLength must be >= 1
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 84
/*Coverage entropy=2.9190235060608334
*/
@Test(timeout = 4000)
public void test84() throws Throwable {
Range range0 = Range.of((-3727L));
Range.Comparators.values();
range0.spliterator();
Range.of((-2798L));
long long0 = range0.getEnd();
assertEquals((-3727L), long0);
}
/**
//Test case number: 85
/*Coverage entropy=3.302527981851437
*/
@Test(timeout = 4000)
public void test85() throws Throwable {
Range range0 = Range.ofLength(929L);
range0.getEnd();
Range.of(928L, 2371L);
Range range1 = Range.of(2371L);
Consumer<Object> consumer0 = (Consumer<Object>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range1.forEach(consumer0);
// Undeclared exception!
try {
Range.Comparators.valueOf("");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.Comparators.
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 86
/*Coverage entropy=3.0998674935555837
*/
@Test(timeout = 4000)
public void test86() throws Throwable {
long long0 = (-3610L);
Range.Builder range_Builder0 = new Range.Builder((-3610L), (-3610L));
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
long long1 = 1871L;
Range.Builder range_Builder1 = new Range.Builder(range_CoordinateSystem0, 1871L, 1871L);
long long2 = (-3786L);
range_Builder1.shift((-1L));
Range range0 = range_Builder1.build();
range_Builder1.copy();
long long3 = 1837L;
range_Builder0.expandBegin(1837L);
Consumer<Long> consumer0 = (Consumer<Long>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
// Undeclared exception!
try {
Range.parseRange("", range_CoordinateSystem0);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// can not parse into a Range
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 87
/*Coverage entropy=3.3918877848097235
*/
@Test(timeout = 4000)
public void test87() throws Throwable {
Range range0 = Range.of(4135L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(255L, 255L);
boolean boolean0 = range0.isSubRangeOf(range1);
assertFalse(boolean0);
Range range2 = Range.of(range_CoordinateSystem0, 4135L, 4135L);
Range range3 = range2.intersection(range0);
assertTrue(range3.isEmpty());
range2.isEmpty();
Range range4 = Range.of(255L);
boolean boolean1 = range0.intersects(range2);
boolean boolean2 = range0.endsBefore(range4);
assertFalse(boolean2);
assertFalse(range0.isEmpty());
boolean boolean3 = range4.intersects(range1);
assertFalse(boolean3 == boolean1);
Range range5 = Range.ofLength(255L);
assertFalse(range5.isEmpty());
}
/**
//Test case number: 88
/*Coverage entropy=3.024695553858248
*/
@Test(timeout = 4000)
public void test88() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 0L, 1243L);
Range.Builder range_Builder0 = new Range.Builder(range0);
Range.Builder range_Builder1 = new Range.Builder(range_Builder0);
assertFalse(range0.isEmpty());
}
/**
//Test case number: 89
/*Coverage entropy=3.316668936831753
*/
@Test(timeout = 4000)
public void test89() throws Throwable {
Range.of(104L, 4294967295L);
Range range0 = Range.of(131L);
Consumer<Long> consumer0 = (Consumer<Long>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
// Undeclared exception!
try {
Range.Comparators.valueOf("");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.Comparators.
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 90
/*Coverage entropy=0.5623351446188083
*/
@Test(timeout = 4000)
public void test90() throws Throwable {
String string0 = "";
// Undeclared exception!
try {
Range.parseRange("");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// can not parse into a Range
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 91
/*Coverage entropy=3.008561077171424
*/
@Test(timeout = 4000)
public void test91() throws Throwable {
Range range0 = Range.ofLength(0L);
long long0 = new Long(0L);
Range range1 = Range.of((-979L));
assertFalse(range1.equals((Object)range0));
}
}
|
3e091e9b920d9c8557a838fd4f45cd07e998017c | 1,548 | java | Java | src/main/java/org/cloudfoundry/identity/migration/DataSourceConfiguration.java | fhanik/uaa-postgresql-mysql-migration | 7567ddf86e9520ea0d46d5e3f2d6254bd946e25a | [
"Apache-2.0"
] | null | null | null | src/main/java/org/cloudfoundry/identity/migration/DataSourceConfiguration.java | fhanik/uaa-postgresql-mysql-migration | 7567ddf86e9520ea0d46d5e3f2d6254bd946e25a | [
"Apache-2.0"
] | null | null | null | src/main/java/org/cloudfoundry/identity/migration/DataSourceConfiguration.java | fhanik/uaa-postgresql-mysql-migration | 7567ddf86e9520ea0d46d5e3f2d6254bd946e25a | [
"Apache-2.0"
] | null | null | null | 28.666667 | 82 | 0.694444 | 3,861 | package org.cloudfoundry.identity.migration;
import com.googlecode.flyway.core.Flyway;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.sql.DataSource;
@Configuration
public class DataSourceConfiguration {
@Bean
@ConfigurationProperties(prefix="datasource.mysql")
public DataSource mysqlDataSource() {
return DataSourceBuilder
.create()
.build();
}
@Bean
@Primary
@ConfigurationProperties(prefix="datasource.postgresql")
public DataSource postgresqlDataSource() {
return DataSourceBuilder
.create()
.build();
}
public void configureFlyway(Flyway flyway, String type) {
flyway.setInitOnMigrate(true);
flyway.setLocations("classpath:org/cloudfoundry/identity/uaa/db/" + type);
flyway.setInitVersion("1.5.2");
}
@Bean
public Flyway mysqlFlyway() {
Flyway flyway = new Flyway();
flyway.setDataSource(mysqlDataSource());
configureFlyway(flyway, "mysql");
return flyway;
}
@Bean
public Flyway postgresqlFlyway() {
Flyway flyway = new Flyway();
flyway.setDataSource(postgresqlDataSource());
configureFlyway(flyway, "postgresql");
return flyway;
}
}
|
3e091fe2359daea588179a8f9fc965590778f4db | 588 | java | Java | src/main/java/com/currencyconverter/utils/CurrenciesList.java | SandeepKmr/CurrencyConverter | c3b67694d86d52b614da5d240a7d345fa58d7948 | [
"MIT"
] | null | null | null | src/main/java/com/currencyconverter/utils/CurrenciesList.java | SandeepKmr/CurrencyConverter | c3b67694d86d52b614da5d240a7d345fa58d7948 | [
"MIT"
] | null | null | null | src/main/java/com/currencyconverter/utils/CurrenciesList.java | SandeepKmr/CurrencyConverter | c3b67694d86d52b614da5d240a7d345fa58d7948 | [
"MIT"
] | null | null | null | 21.777778 | 77 | 0.736395 | 3,862 | package com.currencyconverter.utils;
import java.util.ArrayList;
import java.util.List;
/**
* Provides the static list of currencies for display and calulation purpose.
*
* @author sandeepkumar
*
*/
public class CurrenciesList {
public static List<String> LIST_OF_CURRENCIES = null;
static {
LIST_OF_CURRENCIES = new ArrayList<String>();
LIST_OF_CURRENCIES.add("INR");
LIST_OF_CURRENCIES.add("EUR");
LIST_OF_CURRENCIES.add("AUD");
LIST_OF_CURRENCIES.add("USD");
LIST_OF_CURRENCIES.add("GBP");
LIST_OF_CURRENCIES.add("SGD");
LIST_OF_CURRENCIES.add("CAD");
}
}
|
3e09213064f199f1518fa4318d903b12180c5b33 | 4,791 | java | Java | src/main/java/frc/robot/Robot.java | AndreaDiehl/LED-Test | a5ecc2aaa06a921d02a93206a1772d48fd99dd61 | [
"BSD-3-Clause"
] | null | null | null | src/main/java/frc/robot/Robot.java | AndreaDiehl/LED-Test | a5ecc2aaa06a921d02a93206a1772d48fd99dd61 | [
"BSD-3-Clause"
] | null | null | null | src/main/java/frc/robot/Robot.java | AndreaDiehl/LED-Test | a5ecc2aaa06a921d02a93206a1772d48fd99dd61 | [
"BSD-3-Clause"
] | null | null | null | 29.213415 | 99 | 0.695888 | 3,863 | // Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc.robot;
//why aren't you working
import edu.wpi.first.wpilibj.AddressableLED;
import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import edu.wpi.first.wpilibj.XboxController;
import com.ctre.phoenix.CANifier;
/**
* The VM is configured to automatically run this class, and to call the functions corresponding to
* each mode, as described in the TimedRobot documentation. If you change the name of this class or
* the package after creating this project, you must also update the build.gradle file in the
* project.
*/
public class Robot extends TimedRobot {
private Command m_autonomousCommand;
private RobotContainer m_robotContainer;
public static XboxController controller;
public static AddressableLED m_led;
public static AddressableLEDBuffer m_ledBuffer;
/**
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
@Override
public void robotInit() {
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
// autonomous chooser on the dashboard.
m_robotContainer = new RobotContainer();
m_led = new AddressableLED(9);
// Reuse buffer
// Default to a length of 60, start empty output
// Length is expensive to set, so only set it once, then just update data
m_ledBuffer = new AddressableLEDBuffer(30);
m_led.setLength(m_ledBuffer.getLength());
// Set the data
m_led.setData(m_ledBuffer);
m_led.start();
}
/**
* This function is called every robot packet, no matter the mode. Use this for items like
* diagnostics that you want ran during disabled, autonomous, teleoperated and test.
*
* <p>This runs after the mode specific periodic functions, but before LiveWindow and
* SmartDashboard integrated updating.
*/
@Override
public void robotPeriodic() {
// Runs the Scheduler. This is responsible for polling buttons, adding newly-scheduled
// commands, running already-scheduled commands, removing finished or interrupted commands,
// and running subsystem periodic() methods. This must be called from the robot's periodic
// block in order for anything in the Command-based framework to work.
CommandScheduler.getInstance().run();
}
/** This function is called once each time the robot enters Disabled mode. */
@Override
public void disabledInit() {}
@Override
public void disabledPeriodic() {}
/** This autonomous runs the autonomous command selected by your {@link RobotContainer} class. */
@Override
public void autonomousInit() {
m_autonomousCommand = m_robotContainer.getAutonomousCommand();
// schedule the autonomous command (example)
if (m_autonomousCommand != null) {
m_autonomousCommand.schedule();
}
}
/** This function is called periodically during autonomous. */
@Override
public void autonomousPeriodic() {}
@Override
public void teleopInit() {
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand != null) {
m_autonomousCommand.cancel();
}
}
/** This function is called periodically during operator control. */
@Override
public void teleopPeriodic() {
controller = new XboxController(0);
if (controller.getAButtonPressed()) {
if (true) {
for (var a = 0; a < (m_ledBuffer.getLength()) - 20; a++) {
// Sets the specified LED to the RGB values for red
m_ledBuffer.setRGB(a, 255, 0, 0);
}
m_led.setData(m_ledBuffer);
for (var b = 10; b < m_ledBuffer.getLength() - 10; b++) {
// Sets the specified LED to the RGB values for red
m_ledBuffer.setRGB(b, 0, 255, 0);
}
m_led.setData(m_ledBuffer);
for (var c = 20; c < m_ledBuffer.getLength(); c++) {
// Sets the specified LED to the RGB values for red
m_ledBuffer.setRGB(c, 0, 0, 255);
}
m_led.setData(m_ledBuffer);
}
}
}
@Override
public void testInit() {
// Cancels all running commands at the start of test mode.
CommandScheduler.getInstance().cancelAll();
}
/** This function is called periodically during test mode. */
@Override
public void testPeriodic() {}
}
|
3e0922abbffa666601324a37b8dde8dbe5440a16 | 4,194 | java | Java | src/main/java/org/arend/core/expr/visitor/CollectFreeVariablesVisitor.java | deCybercop/Arend | 2cb5e0aa78e06afed1cd7e422c35bd0da0322035 | [
"Apache-2.0"
] | 1 | 2019-08-12T14:49:55.000Z | 2019-08-12T14:49:55.000Z | src/main/java/org/arend/core/expr/visitor/CollectFreeVariablesVisitor.java | rljacobson/Arend | 2cb5e0aa78e06afed1cd7e422c35bd0da0322035 | [
"Apache-2.0"
] | null | null | null | src/main/java/org/arend/core/expr/visitor/CollectFreeVariablesVisitor.java | rljacobson/Arend | 2cb5e0aa78e06afed1cd7e422c35bd0da0322035 | [
"Apache-2.0"
] | 1 | 2019-08-07T10:10:48.000Z | 2019-08-07T10:10:48.000Z | 32.765625 | 116 | 0.702909 | 3,864 | package org.arend.core.expr.visitor;
import org.arend.core.context.binding.Binding;
import org.arend.core.context.binding.Variable;
import org.arend.core.context.param.DependentLink;
import org.arend.core.definition.Constructor;
import org.arend.core.elimtree.BranchElimTree;
import org.arend.core.elimtree.ElimTree;
import org.arend.core.elimtree.LeafElimTree;
import org.arend.core.expr.*;
import org.arend.core.expr.let.LetClause;
import java.util.*;
import java.util.function.Consumer;
public class CollectFreeVariablesVisitor extends VoidExpressionVisitor<Set<Variable>> {
private Map<Binding, Set<Variable>> myFreeVariables = new HashMap<>();
Set<Variable> getFreeVariables(Binding binding) {
Set<Variable> freeVars = myFreeVariables.get(binding);
return freeVars == null ? Collections.emptySet() : freeVars;
}
private void addFreeVariables(Binding binding, Set<Variable> variables) {
if (!variables.isEmpty()) {
myFreeVariables.computeIfAbsent(binding, k -> new HashSet<>()).addAll(variables);
}
}
@Override
public Void visitReference(ReferenceExpression expr, Set<Variable> variables) {
variables.add(expr.getBinding());
return null;
}
private void visitParameters(DependentLink link, Consumer<Set<Variable>> body, Set<Variable> variables) {
if (!link.hasNext()) {
if (body != null) {
body.accept(variables);
}
return;
}
Set<Variable> newSet = new HashSet<>();
DependentLink link1 = link.getNextTyped(null);
visitParameters(link1.getNext(), body, newSet);
addFreeVariables(link1, newSet);
for (; link != link1; link = link.getNext()) {
newSet.remove(link);
}
newSet.remove(link1);
variables.addAll(newSet);
link1.getTypeExpr().accept(this, variables);
}
@Override
public Void visitLam(LamExpression expr, Set<Variable> variables) {
visitParameters(expr.getParameters(), vars -> expr.getBody().accept(this, vars), variables);
return null;
}
@Override
public Void visitPi(PiExpression expr, Set<Variable> variables) {
visitParameters(expr.getParameters(), vars -> expr.getCodomain().accept(this, vars), variables);
return null;
}
@Override
public Void visitSigma(SigmaExpression expr, Set<Variable> variables) {
visitParameters(expr.getParameters(), null, variables);
return null;
}
@Override
public Void visitLet(LetExpression expr, Set<Variable> variables) {
visitLetClauses(0, expr, variables);
return null;
}
private void visitLetClauses(int index, LetExpression expr, Set<Variable> variables) {
if (index == expr.getClauses().size()) {
expr.getExpression().accept(this, variables);
return;
}
Set<Variable> newSet = new HashSet<>();
visitLetClauses(index + 1, expr, newSet);
LetClause clause = expr.getClauses().get(index);
addFreeVariables(clause, newSet);
newSet.remove(clause);
variables.addAll(newSet);
clause.getExpression().accept(this, variables);
}
@Override
public Void visitCase(CaseExpression expr, Set<Variable> variables) {
for (Expression arg : expr.getArguments()) {
arg.accept(this, variables);
}
visitParameters(expr.getParameters(), vars -> {
expr.getResultType().accept(this, vars);
if (expr.getResultTypeLevel() != null) {
expr.getResultTypeLevel().accept(this, vars);
}
}, variables);
visitParameters(expr.getElimTree().getParameters(), vars -> visitElimTree(expr.getElimTree(), vars), variables);
return null;
}
@Override
protected void visitElimTree(ElimTree elimTree, Set<Variable> variables) {
if (elimTree instanceof LeafElimTree) {
((LeafElimTree) elimTree).getExpression().accept(this, variables);
} else {
for (Map.Entry<Constructor, ElimTree> entry : ((BranchElimTree) elimTree).getChildren()) {
visitParameters(entry.getValue().getParameters(), vars -> visitElimTree(entry.getValue(), vars), variables);
}
}
}
@Override
public Void visitDefCall(DefCallExpression expr, Set<Variable> variables) {
variables.add(expr.getDefinition());
return super.visitDefCall(expr, variables);
}
}
|
3e0924e0c2e337d38b1aad92a5c6b82d1d9a2a3d | 3,212 | java | Java | GameEngine/src/water/WaterRenderer.java | jaymcole/3DEngine | 1dd66fc17ff933ee56488c53c7005cfd93a37334 | [
"MIT"
] | null | null | null | GameEngine/src/water/WaterRenderer.java | jaymcole/3DEngine | 1dd66fc17ff933ee56488c53c7005cfd93a37334 | [
"MIT"
] | null | null | null | GameEngine/src/water/WaterRenderer.java | jaymcole/3DEngine | 1dd66fc17ff933ee56488c53c7005cfd93a37334 | [
"MIT"
] | null | null | null | 30.301887 | 110 | 0.698941 | 3,865 | package water;
import java.util.List;
import models.RawModel;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Vector3f;
import engineTester.MainGameLoop;
import renderEngine.DisplayManager;
import renderEngine.Loader;
import toolbox.Maths;
import entities.Camera;
import entities.Light;
public class WaterRenderer {
private static final String DUDV_MAP = "waterDUDV";
private static final String NORMAL_MAP = "normal";
private static final float WAVE_SPEED = 0.03f;
private RawModel quad;
private WaterShader shader;
private WaterFrameBuffers fbos;
private int dudvTexture;
private int normalMap;
private float moveFactor = 0;
public WaterRenderer(Loader loader, WaterShader shader, Matrix4f projectionMatrix, WaterFrameBuffers fbos) {
this.shader = shader;
this.fbos = fbos;
dudvTexture = loader.loadTexture(DUDV_MAP);
normalMap = loader.loadTexture(NORMAL_MAP);
shader.start();
shader.connectTextureUnits();
shader.loadProjectionMatrix(projectionMatrix);
shader.stop();
setUpVAO(loader);
}
public void render(List<WaterTile> water, Camera camera, Light light) {
prepareRender(camera, light);
for (WaterTile tile : water) {
Matrix4f modelMatrix = Maths.createTransformationMatrix(
new Vector3f(tile.getX(), tile.getHeight(), tile.getZ()), 0, 0, 0,
MainGameLoop.WATER_TILE_SIZE);
shader.loadModelMatrix(modelMatrix);
GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, quad.getVertexCount());
}
unbind();
}
private void prepareRender(Camera camera, Light light){
shader.start();
shader.loadViewMatrix(camera);
moveFactor += WAVE_SPEED * DisplayManager.getFrameTimeSeconds();
moveFactor %= 1;
shader.loadMoveFactor(moveFactor);
shader.loadLight(light);
GL30.glBindVertexArray(quad.getVaoID());
GL20.glEnableVertexAttribArray(0);
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getReflectionTexture());
GL13.glActiveTexture(GL13.GL_TEXTURE1);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getRefractionTexture());
GL13.glActiveTexture(GL13.GL_TEXTURE2);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, dudvTexture);
GL13.glActiveTexture(GL13.GL_TEXTURE3);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, normalMap);
GL13.glActiveTexture(GL13.GL_TEXTURE4);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getRefractionDepthTexture());
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
private void unbind(){
GL11.glDisable(GL11.GL_BLEND);
GL20.glDisableVertexAttribArray(0);
GL30.glBindVertexArray(0);
shader.stop();
}
private void setUpVAO(Loader loader) {
// Just x and z vectex positions here, y is set to 0 in v.shader
float[] vertices = { -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1 };
quad = loader.loadVAO(vertices, 2);
}
}
|
3e09250c8ecff4fbe5a85c3746a9536c08a6c984 | 5,877 | java | Java | oim-server-run/cloud/service/work/group/oim-server-module-work-group-function-business/src/main/java/com/oimchat/server/general/kernel/work/module/business/group/action/GroupJoinAction.java | oimchat/oim-server | 55c1a317251b9a219aad6e24925bc423214a8c3d | [
"Apache-2.0"
] | 12 | 2021-01-28T07:50:32.000Z | 2022-03-17T09:27:43.000Z | oim-server-run/cloud/service/work/group/oim-server-module-work-group-function-business/src/main/java/com/oimchat/server/general/kernel/work/module/business/group/action/GroupJoinAction.java | yuzhanxu/oim-server | dbb087778bc28e04ffefbe39ff9e1200578c9dc8 | [
"Apache-2.0"
] | 1 | 2021-03-05T10:17:03.000Z | 2021-03-05T11:00:53.000Z | oim-server-run/cloud/service/work/group/oim-server-module-work-group-function-business/src/main/java/com/oimchat/server/general/kernel/work/module/business/group/action/GroupJoinAction.java | yuzhanxu/oim-server | dbb087778bc28e04ffefbe39ff9e1200578c9dc8 | [
"Apache-2.0"
] | 6 | 2021-02-09T08:07:53.000Z | 2022-02-28T08:04:38.000Z | 30.931579 | 107 | 0.739493 | 3,866 | package com.oimchat.server.general.kernel.work.module.business.group.action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import com.oimchat.server.basic.common.work.app.UserSession;
import com.oimchat.server.general.kernel.work.module.base.group.data.dto.GroupJoinApplyData;
import com.oimchat.server.general.kernel.work.module.base.group.data.dto.GroupJoinHandleData;
import com.oimchat.server.general.kernel.work.module.base.group.data.dto.JoinVerifyAnswer;
import com.oimchat.server.general.kernel.work.module.base.group.data.query.GroupJoinApplyEntityCase;
import com.oimchat.server.general.kernel.work.module.base.group.data.query.GroupJoinApplyQuery;
import com.oimchat.server.general.kernel.work.module.base.group.entity.GroupJoinApply;
import com.oimchat.server.general.kernel.work.module.base.group.entity.GroupJoinVerifyAnswer;
import com.oimchat.server.general.kernel.work.module.business.group.service.GroupJoinService;
import com.oimchat.server.general.kernel.work.module.business.group.service.GroupJoinSettingService;
import com.oimchat.server.general.kernel.work.module.business.group.service.GroupJoinVerifyAnswerService;
import com.oimchat.server.general.kernel.work.module.business.group.service.GroupManageService;
import com.onlyxiahui.common.annotation.parameter.Define;
import com.onlyxiahui.common.data.common.bean.CountInfo;
import com.onlyxiahui.common.data.common.data.Page;
import com.onlyxiahui.common.data.common.data.PageResult;
import com.onlyxiahui.common.message.bean.Info;
import com.onlyxiahui.framework.action.dispatcher.annotation.ActionMapping;
/**
* 加入群业务接口<br>
* Date 2019-01-20 20:49:52<br>
*
* @author XiaHui<br>
* @since 1.0.0
* @docModuleSuperKey 1.3.0
*/
@Component
@ActionMapping(value = "1.3.007")
public class GroupJoinAction {
@Resource
private GroupJoinSettingService groupJoinSettingService;
@Resource
private GroupJoinService groupJoinService;
@Resource
private GroupManageService groupManageService;
@Resource
private GroupJoinVerifyAnswerService groupJoinVerifyAnswerService;
/**
* 获取申请加入数量(群主/管理员)<br>
* Date 2019-01-27 10:39:08<br>
*
* @author XiaHui<br>
* @param userSession
* @return
* @since 1.0.0
*/
@ActionMapping(value = "1.1.0001")
public CountInfo queryJoinApplyReceiveCount(
UserSession userSession,
@Define("body.query") GroupJoinApplyQuery query) {
Page page = new Page();
page.setSize(1);
String userId = userSession.getUserId();
groupManageService.queryJoinRequestList(userId, query, page);
return new CountInfo(page.getTotalCount());
}
/**
* 获取申请加入列表(群主/管理员)<br>
* Date 2019-01-27 10:39:08<br>
*
* @author XiaHui<br>
* @param userSession
* @return
* @since 1.0.0
*/
@ActionMapping(value = "1.1.0002")
public PageResult<List<GroupJoinApply>> queryJoinApplyReceiveList(
UserSession userSession,
@Define("body.query") GroupJoinApplyQuery query,
@Define("body.page") Page page) {
String userId = userSession.getUserId();
List<GroupJoinApply> applys = groupManageService.queryJoinRequestList(userId, query, page);
return new PageResult<>(page, applys);
}
/**
*
* 获取申请加入详情列表(群主/管理员)<br>
* Date 2020-04-11 20:05:25<br>
*
* @param userSession
* @param query
* @param page
* @return
* @since 1.0.0
*/
@ActionMapping(value = "1.1.0003")
public PageResult<List<GroupJoinApplyEntityCase>> queryJoinApplyDataReceiveList(
UserSession userSession,
@Define("body.query") GroupJoinApplyQuery query,
@Define("body.page") Page page) {
String userId = userSession.getUserId();
List<String> applyIds = new ArrayList<>();
List<String> groupIds = new ArrayList<>();
List<GroupJoinApply> applys = groupManageService.queryJoinRequestList(userId, query, page);
for (GroupJoinApply ap : applys) {
groupIds.add(ap.getGroupId());
applyIds.add(ap.getId());
}
Map<String, List<GroupJoinVerifyAnswer>> answerMap = new HashMap<>();
List<GroupJoinVerifyAnswer> answers = groupJoinVerifyAnswerService.getListByApplyIds(groupIds, applyIds);
for (GroupJoinVerifyAnswer a : answers) {
String aid = a.getApplyId();
List<GroupJoinVerifyAnswer> list = answerMap.get(aid);
if (null == list) {
list = new ArrayList<>();
answerMap.put(aid, list);
}
list.add(a);
}
List<GroupJoinApplyEntityCase> list = new ArrayList<>();
for (GroupJoinApply ap : applys) {
String aid = ap.getId();
List<GroupJoinVerifyAnswer> answerList = answerMap.get(aid);
list.add(new GroupJoinApplyEntityCase(ap, answerList));
}
return new PageResult<>(page, list);
}
/**
* 处理加入申请<br>
* Date 2019-01-26 14:44:23<br>
*
* @author XiaHui<br>
* @param userSession
* @param handle
* @return
* @since 1.0.0
*/
@ActionMapping(value = "1.1.0005")
public Info joinHandle(
UserSession userSession,
@Define("body.handle") GroupJoinHandleData handle) {
// String applyId;// 请求记录id
// String applyUserId;// 添加联系人的请求用户
// String groupId;// 被添加的用户
// String handleType;// 处理结果:0:未处理 1:同意 2:拒绝 3:忽略
// String message;// 附加消息
String handleUserId = userSession.getUserId();
handle.setHandleUserId(handleUserId);
Info info = groupJoinService.joinHandle(handle);
return info;
}
/**
* 申请加入<br>
* Date 2019-01-26 14:43:22<br>
*
* @author XiaHui<br>
* @param userSession
* @param apply
* @param answers
* @return
* @since 1.0.0
*/
@ActionMapping(value = "1.1.0006")
public Info joinRequest(
UserSession userSession,
@Define("body.apply") GroupJoinApplyData apply,
@Define("body.answers") List<JoinVerifyAnswer> answers) {
String userId = userSession.getUserId();
apply.setApplyUserId(userId);
Info info = groupJoinService.joinApply(apply, answers);
return info;
}
}
|
3e09251b0ac026507304f4a1546f83d33b9065ac | 2,275 | java | Java | module/platform-pay/src/main/java/sivl/platform/pay/sdk/alipay/common/config/AlipayConfig.java | zhouxiang91160/platform_v1.0 | 187d74297f235e5b9faa4502c98023db932eeac0 | [
"Apache-2.0"
] | null | null | null | module/platform-pay/src/main/java/sivl/platform/pay/sdk/alipay/common/config/AlipayConfig.java | zhouxiang91160/platform_v1.0 | 187d74297f235e5b9faa4502c98023db932eeac0 | [
"Apache-2.0"
] | null | null | null | module/platform-pay/src/main/java/sivl/platform/pay/sdk/alipay/common/config/AlipayConfig.java | zhouxiang91160/platform_v1.0 | 187d74297f235e5b9faa4502c98023db932eeac0 | [
"Apache-2.0"
] | null | null | null | 28.08642 | 91 | 0.687033 | 3,867 | package sivl.platform.pay.sdk.alipay.common.config;
/* *
*类名:AlipayConfig
*功能:基础配置类
*详细:设置帐户有关信息及返回路径
*版本:3.3
*日期:2012-08-10
*说明:
*以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
*该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
*提示:如何获取安全校验码和合作身份者ID
*1.用您的签约支付宝账号登录支付宝网站(www.alipay.com)
*2.点击“商家服务”(https://b.alipay.com/order/myOrder.htm)
*3.点击“查询合作者身份(PID)”、“查询安全校验码(Key)”
*安全校验码查看时,输入支付密码后,页面呈灰色的现象,怎么办?
*解决方法:
*1、检查浏览器配置,不让浏览器做弹框屏蔽设置
*2、更换浏览器或电脑,重新登录查询。
*/
public class AlipayConfig {
// 合作身份者ID,以2088开头由16位纯数字组成的字符串
public static String partner = null;
// 商户的私钥
public static String key = null;
// 卖家账户
public static String seller = null;
// 调试用,创建TXT日志文件夹路径
public static String log_path = null;
// 字符编码格式 目前支持 gbk 或 utf-8
public static String input_charset = "utf-8";
// 签名方式 不需修改
public static String sign_type = "MD5";
// web支付前台通知
public static String web_payment_return = null;
// web支付异步通知
public static String web_payment_notify = null;
// 退款异步通知
public static String refundment_notify = null;
// 支付接口
public static String service_payment = "create_direct_pay_by_user";
// 支付类型
public static String payment_type = "1";
// 超时时间
public static String it_b_pay = "15d";
// -----------------wap参数---------------------------
//WAP签名方式
public static String wap_sign_type = "0001";
// 支付宝网关地址
public static String ALIPAY_GATEWAY_NEW = "http://wappaygw.alipay.com/service/rest.htm?";
// 授权接口
public static String service_auth = "alipay.wap.trade.create.direct";
// 交易接口
public static String service_trade = "alipay.wap.auth.authAndExecute";
// 无线支付私钥
public static String private_key = null;
// wap专用公钥
public static String wap_public_key = null;
// wap支付前台通知
public static String wap_payment_return = null;
// wap支付异步通知
public static String wap_payment_notify = null;
//默认超时时间
public static String pay_expire = "21600";
// ------------------app参数---------------------------
//交易接口
public static String app_service = "mobile.securitypay.pay";
// 签名方式 不需修改
public static String app_sign_type = "RSA";
// app专用公钥与wap公用私钥
public static String app_public_key = null;
// app支付异步通知
public static String app_payment_notify = null;
}
|
3e0926ebeb82f70cb94a93d6f13c9bb4a94bd916 | 1,749 | java | Java | snuggletex-core/src/main/java/uk/ac/ed/ph/snuggletex/definitions/BuiltinEnvironment.java | davemckain/snuggletex | 1d694f9e07bef4dd99792cca5d5eaade76663f1f | [
"BSD-3-Clause"
] | null | null | null | snuggletex-core/src/main/java/uk/ac/ed/ph/snuggletex/definitions/BuiltinEnvironment.java | davemckain/snuggletex | 1d694f9e07bef4dd99792cca5d5eaade76663f1f | [
"BSD-3-Clause"
] | null | null | null | snuggletex-core/src/main/java/uk/ac/ed/ph/snuggletex/definitions/BuiltinEnvironment.java | davemckain/snuggletex | 1d694f9e07bef4dd99792cca5d5eaade76663f1f | [
"BSD-3-Clause"
] | null | null | null | 35.693878 | 107 | 0.73299 | 3,868 | /* Copyright (c) 2008-2011, The University of Edinburgh.
* All Rights Reserved
*/
package uk.ac.ed.ph.snuggletex.definitions;
import uk.ac.ed.ph.snuggletex.SnugglePackage;
import uk.ac.ed.ph.snuggletex.dombuilding.EnvironmentHandler;
import uk.ac.ed.ph.snuggletex.semantics.Interpretation;
import uk.ac.ed.ph.snuggletex.semantics.InterpretationType;
import java.util.EnumMap;
import java.util.EnumSet;
/**
* Defines a built-in LaTeX environment, as specified within a {@link SnugglePackage}.
*
* @see BuiltinCommand
* @see CorePackageDefinitions
*
* @author David McKain
*/
public final class BuiltinEnvironment extends BuiltinCommandOrEnvironment<EnvironmentHandler>
implements Environment {
/**
* Mode to use when parsing content. If null, will preserve mode that environment
* is called in.
*/
private final LaTeXMode contentMode;
public BuiltinEnvironment(final String texName, final boolean allowingOptionalArgument,
final int argumentCount, final EnumSet<LaTeXMode> allowedModes,
final LaTeXMode contentMode, final EnumMap<InterpretationType, Interpretation> interpretations,
final EnvironmentHandler domBuildingHandler, final TextFlowContext textFlowContext) {
super(texName, allowingOptionalArgument, argumentCount, allowedModes, interpretations,
textFlowContext, domBuildingHandler);
this.contentMode = contentMode;
}
/** (Currently all built-in environments parse their arguments in {@link LaTeXMode#PARAGRAPH}.) */
public LaTeXMode getArgumentMode(int argumentIndex) {
return LaTeXMode.PARAGRAPH;
}
public LaTeXMode getContentMode() {
return contentMode;
}
}
|
3e0928535713c3d3739c4ba8e99122d565b7fa7d | 744 | java | Java | src/main/java/io/virusafe/exception/UnverifiableRefreshTokenException.java | scalefocus/virusafe-backend | 359b675f74fc634a5ddeaca49914ae47d9207333 | [
"Apache-2.0"
] | 12 | 2020-04-23T17:27:49.000Z | 2020-06-21T13:54:39.000Z | src/main/java/io/virusafe/exception/UnverifiableRefreshTokenException.java | scalefocus/virusafe-backend | 359b675f74fc634a5ddeaca49914ae47d9207333 | [
"Apache-2.0"
] | 9 | 2020-04-23T14:46:42.000Z | 2020-05-29T12:26:41.000Z | src/main/java/io/virusafe/exception/UnverifiableRefreshTokenException.java | scalefocus/virusafe-backend | 359b675f74fc634a5ddeaca49914ae47d9207333 | [
"Apache-2.0"
] | 1 | 2020-05-29T07:18:56.000Z | 2020-05-29T07:18:56.000Z | 29.76 | 100 | 0.735215 | 3,869 | package io.virusafe.exception;
import org.springframework.security.core.AuthenticationException;
public class UnverifiableRefreshTokenException extends AuthenticationException {
private static final String ERROR_MESSAGE = "Refresh token can not be verified!";
/**
* Construct a new UnverifiableRefreshTokenException with the pre-set message.
*/
public UnverifiableRefreshTokenException() {
super(ERROR_MESSAGE);
}
/**
* Construct a new UnverifiableRefreshTokenException with the pre-set message and a given cause.
*
* @param throwable the Throwable cause
*/
public UnverifiableRefreshTokenException(final Throwable throwable) {
super(ERROR_MESSAGE, throwable);
}
}
|
3e0928b69db4e2e101a22aa3ae12ef8a83d749fa | 3,595 | java | Java | backend/media/src/test/java/co/airy/core/media/MediaControllerTest.java | vruksheco/airy-ek | f5d12515739bc16484b9026506464975652978a9 | [
"Apache-2.0"
] | 275 | 2020-11-03T15:07:46.000Z | 2022-03-27T21:57:01.000Z | backend/media/src/test/java/co/airy/core/media/MediaControllerTest.java | LJCoopz/airy | 893e8d5dc8e724cd788df80454a7557e35bdd0b9 | [
"Apache-2.0"
] | 1,359 | 2020-11-03T15:09:48.000Z | 2022-03-31T14:55:13.000Z | backend/media/src/test/java/co/airy/core/media/MediaControllerTest.java | LJCoopz/airy | 893e8d5dc8e724cd788df80454a7557e35bdd0b9 | [
"Apache-2.0"
] | 36 | 2020-11-24T09:55:41.000Z | 2022-03-11T21:19:30.000Z | 36.683673 | 110 | 0.753825 | 3,870 | package co.airy.core.media;
import co.airy.core.media.services.MediaUpload;
import co.airy.kafka.test.KafkaTestHelper;
import co.airy.kafka.test.junit.SharedKafkaTestResource;
import co.airy.spring.core.AirySpringBootApplication;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.PutObjectRequest;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import java.io.InputStream;
import static co.airy.test.Timing.retryOnException;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest(classes = AirySpringBootApplication.class)
@TestPropertySource(value = "classpath:test.properties")
@AutoConfigureMockMvc
@ExtendWith(SpringExtension.class)
public class MediaControllerTest {
@RegisterExtension
public static final SharedKafkaTestResource sharedKafkaTestResource = new SharedKafkaTestResource();
private static KafkaTestHelper kafkaTestHelper;
@BeforeAll
static void beforeAll() throws Exception {
kafkaTestHelper = new KafkaTestHelper(sharedKafkaTestResource);
kafkaTestHelper.beforeAll();
}
@AfterAll
static void afterAll() throws Exception {
kafkaTestHelper.afterAll();
}
MediaUpload mediaUpload;
@MockBean
private AmazonS3 amazonS3;
@Autowired
private MockMvc mvc;
@Value("${s3.bucket}")
private String bucket;
@Value("${s3.path}")
private String path;
@BeforeEach
void beforeEach() throws Exception {
MockitoAnnotations.openMocks(this);
mediaUpload = new MediaUpload(amazonS3, bucket, path);
}
@Test
void shouldCallS3ToUploadImageDirect() throws Exception {
final InputStream is = getClass().getResourceAsStream("giphy.gif");
MockMultipartFile mockMultipartFile = new MockMultipartFile("file", "giphy.gif",
MediaType.MULTIPART_FORM_DATA_VALUE, is);
MockMultipartHttpServletRequestBuilder builder =
(MockMultipartHttpServletRequestBuilder) MockMvcRequestBuilders.multipart("/media.upload")
.file(mockMultipartFile)
.contentType(MediaType.MULTIPART_FORM_DATA_VALUE);
retryOnException(
() -> {
mvc.perform(builder).andExpect(status().isOk());
Mockito.verify(amazonS3, Mockito.times(1)).putObject(Mockito.any(PutObjectRequest.class));
},
"Something went wrong while uploading an image"
);
}
}
|
3e0929af93f436a9852d2b51689b8cb0c8b5b5f8 | 567 | java | Java | TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/functional_interfaces/QuadFunction.java | SCHS-Robotics/HAL9001Legacy | a7a678ccc84a21837eeb6639d04bd084fc451efd | [
"MIT"
] | null | null | null | TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/functional_interfaces/QuadFunction.java | SCHS-Robotics/HAL9001Legacy | a7a678ccc84a21837eeb6639d04bd084fc451efd | [
"MIT"
] | null | null | null | TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/functional_interfaces/QuadFunction.java | SCHS-Robotics/HAL9001Legacy | a7a678ccc84a21837eeb6639d04bd084fc451efd | [
"MIT"
] | null | null | null | 24.652174 | 66 | 0.66843 | 3,871 | /*
* Filename: QuadFunction.java
* Author: Cole Savage
* Team Name: Level Up
* Date: 7/18/19
*/
package org.firstinspires.ftc.teamcode.util.functional_interfaces;
/**
* An arbitrary function with 4 inputs and 1 output.
*
* @param <T> - The datatype of the first input.
* @param <R> - The datatype of the second input.
* @param <S> - The datatype of the third input.
* @param <Q> - The datatype of the fourth input.
* @param <P> - The datatype of the output.
*/
public interface QuadFunction<T,R,S,Q,P> {
P apply(T arg1, R arg2, S arg3, Q arg4);
}
|
3e0929cea9ddb3a3b21779b3a842e04396e12841 | 7,424 | java | Java | TeamCode/src/main/java/UserControlled/RosannaV4.java | botsofprey/GirlScoutOutreach | f6e65ed310b1722211d9c204a71e770de797da75 | [
"MIT"
] | null | null | null | TeamCode/src/main/java/UserControlled/RosannaV4.java | botsofprey/GirlScoutOutreach | f6e65ed310b1722211d9c204a71e770de797da75 | [
"MIT"
] | null | null | null | TeamCode/src/main/java/UserControlled/RosannaV4.java | botsofprey/GirlScoutOutreach | f6e65ed310b1722211d9c204a71e770de797da75 | [
"MIT"
] | null | null | null | 42.422857 | 218 | 0.614763 | 3,872 | //package UserControlled;
//
//import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
//import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
//
//import Actions.LatchSystemV4;
//import Actions.MineralSystemV4;
//import Autonomous.Location;
//import DriveEngine.HolonomicDriveSystemTesting;
//
///**
// * Created by robotics on 2/16/18.
// */
//@TeleOp(name="Rosanna v4", group="User Controlled") // @Autonomous(...) is the other common choice
////@Disabled
//public class RosannaV4 extends LinearOpMode {
// final double movementScale = 1;
// double turningScale = .75;
// boolean intaking = false, slowMode = false, latched = false;
// boolean p1Driving = true, flagWaving = false, trackingLocation = false;
// boolean aReleased = true, startReleased = true, dpadLReleased = true, a2Released = true, slowToggle = true, xReleased = true;
// long initialLatchPos = 0;
//
// JoystickHandler leftStick, rightStick, gamepad2LeftStick, gamepad2RightStick;
// MineralSystemV4 mineralSystem;
// LatchSystemV4 latchSystem;
// HolonomicDriveSystemTesting navigation;
//
// @Override
// public void runOpMode() throws InterruptedException {
// try {
// navigation = new HolonomicDriveSystemTesting(hardwareMap, new Location(0, 0), 0, "RobotConfig/RosannaV4.json");
// } catch (Exception e) {
// e.printStackTrace();
// throw new RuntimeException(e);
// }
// mineralSystem = new MineralSystemV4(hardwareMap);
// latchSystem = new LatchSystemV4(hardwareMap);
// leftStick = new JoystickHandler(gamepad1, JoystickHandler.LEFT_JOYSTICK);
// rightStick = new JoystickHandler(gamepad1, JoystickHandler.RIGHT_JOYSTICK);
// gamepad2LeftStick = new JoystickHandler(gamepad2, JoystickHandler.LEFT_JOYSTICK);
// gamepad2RightStick = new JoystickHandler(gamepad2, JoystickHandler.RIGHT_JOYSTICK);
//// flagController = new FlagControllerTwoArms(hardwareMap);
// initialLatchPos = latchSystem.winchMotor.getCurrentTick();
//
//// camera.startTrackingLocation();
//
// telemetry.addData("Status", "Initialized!");
// telemetry.addData("OpMode Active", opModeIsActive());
// telemetry.update();
// while (!opModeIsActive()) latchSystem.pause();
// waitForStart();
//
//
// while(opModeIsActive()){
// turningScale = (mineralSystem.MAX_EXTEND_INCHES - mineralSystem.extensionMotor.getPositionInches()) / mineralSystem.MAX_EXTEND_INCHES;
//
// handleDriving();
// handleMineralSystem();
// handleLatchSystem();
//
//// if(dpadLReleased && gamepad2.dpad_left) {
//// dpadLReleased = false;
//// flagWaving = !flagWaving;
//// } else if(!dpadLReleased && !gamepad2.dpad_left) {
//// dpadLReleased = true;
//// }
////
//// if(flagWaving) flagController.startFlag();
//// else flagController.pauseFlag();
//
// telemetry.addData("Gamepad1 left Joystick",leftStick.y());
// telemetry.addData("Gamepad1 right Joystick", rightStick.y());
// telemetry.addData("Gamepad1 right Trigger", gamepad1.right_trigger);
// telemetry.addData("Arm Radius (ticks)", mineralSystem.extensionMotor.getPosition());
// telemetry.addData("Arm Rotation (ticks)", mineralSystem.liftMotor.getCurrentTick());
// telemetry.addData("Latch Extention (ticks)", latchSystem.winchMotor.getCurrentTick());
//
// telemetry.update();
// }
// mineralSystem.kill();
// navigation.kill();
// latchSystem.kill();
// }
//
// private void handleDriving() {
// if(startReleased && (gamepad1.start || gamepad2.start)) {
// startReleased = false;
// p1Driving = !p1Driving;
// } else if(!startReleased && !gamepad1.start && !gamepad2.start) {
// startReleased = true;
// }
//
// if(slowToggle && !gamepad1.dpad_down) {
// slowMode = false;
// slowToggle = false;
// }
// else if(!slowToggle && gamepad1.dpad_down) {
// slowToggle = true;
// }
//
// if(xReleased && gamepad1.x) {
// xReleased = false;
// intaking = false;
// slowMode = !slowMode;
// } else if(!xReleased && !gamepad1.x) {
// xReleased = true;
// }
//
// if(p1Driving) {
// double movementPower = (slowMode)? 0.25 * movementScale * Math.abs(leftStick.magnitude()):movementScale * Math.abs(leftStick.magnitude());
// double turningPower = (slowMode)? 0.25 * turningScale * Math.abs(rightStick.magnitude()) * Math.signum(rightStick.x()): 0.5 * turningScale * Math.abs(rightStick.magnitude()) * Math.signum(rightStick.x());
// navigation.driveOnHeadingWithTurning(leftStick.angle() + 180, movementPower, (intaking)? 0.5 * turningPower:turningPower);
// telemetry.addData("Joystick angle", leftStick.angle());
// } else {
// double movementPower = 0.5 * movementScale * Math.abs(gamepad2LeftStick.magnitude());
// double turningPower = 0.55 * turningScale * Math.abs(gamepad2RightStick.magnitude()) * Math.signum(gamepad2RightStick.x());
// navigation.driveOnHeadingWithTurning(gamepad2LeftStick.angle() + 270, movementPower, turningPower);
// }
// }
//
// private void handleMineralSystem() {
// if(gamepad1.left_trigger > 0.1) mineralSystem.liftOrLower(-gamepad1.left_trigger * 0.5);
// else if(gamepad2.left_trigger > 0.1) mineralSystem.liftOrLower(gamepad2.left_trigger);
// else if(gamepad1.left_bumper) mineralSystem.lift();
// else if(gamepad2.left_bumper) mineralSystem.liftOrLower(-0.75);
// else mineralSystem.pauseLift();
//
// if(aReleased && (gamepad1.a)) {
// aReleased = false;
// intaking = !intaking;
// } else if(!aReleased && !gamepad1.a) {
// aReleased = true;
// }
//
//
// if(intaking && !gamepad1.b) mineralSystem.intake();
// else if(gamepad1.b) {
// mineralSystem.expel();
// } else mineralSystem.pauseCollection();
//
//
// if(gamepad1.dpad_down) {
// mineralSystem.openDoor();
// intaking = true;
// }
// else mineralSystem.closeDoor();
//
// if(gamepad1.right_trigger > 0.1 || gamepad2.right_trigger > 0.1) mineralSystem.extendIntake();
// else if(gamepad1.right_bumper || gamepad2.right_bumper) mineralSystem.retractIntake();
// else mineralSystem.pauseExtension();
//
// if(gamepad2.a) mineralSystem.goToPosition(MineralSystemV4.DEPOSIT_POSITION_NO_POLAR);
//
// if(gamepad2.dpad_right) {
// mineralSystem.setDepositTargetPosition();
// }
// }
//
// private void handleLatchSystem(){
// if(gamepad2.dpad_up) {
// latchSystem.retract();
// latched = true;
// }
// else if(gamepad2.dpad_down) {
// latchSystem.extend();
// latched = false;
// }
// else if(gamepad2.x) latchSystem.extendUnsafe();
// else if(gamepad2.y) latchSystem.retractUnsafe();
// else if(latched) latchSystem.pause();
// else latchSystem.winchMotor.brake();
// }
//}
|
3e092a6ac663382560b752035d02f533021513bb | 473 | java | Java | src/main/java/jroid/kakaotalk/server/entity/item/EquipEvent.java | Jroid-KakaoTalk/Server | 42e1a27a60a1f29c4dcf31a914611185d09a0092 | [
"MIT"
] | 1 | 2022-03-08T08:37:42.000Z | 2022-03-08T08:37:42.000Z | src/main/java/jroid/kakaotalk/server/entity/item/EquipEvent.java | Jroid-KakaoTalk/Server | 42e1a27a60a1f29c4dcf31a914611185d09a0092 | [
"MIT"
] | null | null | null | src/main/java/jroid/kakaotalk/server/entity/item/EquipEvent.java | Jroid-KakaoTalk/Server | 42e1a27a60a1f29c4dcf31a914611185d09a0092 | [
"MIT"
] | null | null | null | 17.518519 | 60 | 0.69556 | 3,873 | package jroid.kakaotalk.server.entity.item;
import lombok.*;
import javax.persistence.*;
@Entity
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EquipEvent {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column
Long id;
@Column(columnDefinition = "SMALLINT UNSIGNED NOT NULL")
Integer event;
@ManyToOne
@JoinColumn(name = "equip_id", nullable = false)
Equipment equipment;
} |
3e092a6cbbf6bcc8b0f7dfc4038fe05b2a39163a | 1,913 | java | Java | src/main/java/com/gongsir/wxapp/controller/wxapi/IndexController.java | gongsir0630/LostAndFoundOnCampus | a070bd4a3366a7a84fd1afb36e5948b9101c7826 | [
"MIT"
] | 15 | 2021-04-07T03:30:04.000Z | 2022-03-23T04:22:19.000Z | src/main/java/com/gongsir/wxapp/controller/wxapi/IndexController.java | gongsir0630/LostAndFoundOnCampus | a070bd4a3366a7a84fd1afb36e5948b9101c7826 | [
"MIT"
] | null | null | null | src/main/java/com/gongsir/wxapp/controller/wxapi/IndexController.java | gongsir0630/LostAndFoundOnCampus | a070bd4a3366a7a84fd1afb36e5948b9101c7826 | [
"MIT"
] | 3 | 2021-04-05T15:37:44.000Z | 2022-03-13T09:46:17.000Z | 34.781818 | 95 | 0.690016 | 3,874 | package com.gongsir.wxapp.controller.wxapi;
import com.alibaba.fastjson.JSONObject;
import com.gongsir.wxapp.model.Image;
import com.gongsir.wxapp.model.Notice;
import com.gongsir.wxapp.service.ImageService;
import com.gongsir.wxapp.service.NoticeService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @author gongsir
* @date 2020/2/24 12:44
* 编码不要畏惧变化,要拥抱变化
*/
@Api(tags = "小程序首页公告、轮播图相关接口")
@RestController
@RequestMapping(value = "/wxApi/index")
public class IndexController {
@Resource
private NoticeService noticeService;
@Resource
private ImageService imageService;
@GetMapping(path = "notices")
public JSONObject getNotices(@RequestParam(value = "page",defaultValue = "1") int page,
@RequestParam(value = "limit",defaultValue = "10") int limit){
JSONObject res = new JSONObject();
//获取公告内容
List<Notice> notices = noticeService.getAllNotices("ok", page, limit);
long count = noticeService.countAllNotices("ok");
res.put("notices",notices);
res.put("notice_count",count);
return res;
}
@GetMapping(path = "images")
public JSONObject getAllImages(@RequestParam(value = "page",defaultValue = "1") int page,
@RequestParam(value = "limit",defaultValue = "10") int limit){
JSONObject res = new JSONObject();
List<Image> images = imageService.getAllImages("ok", page, limit);
long count = imageService.countAllImages("ok");
res.put("images",images);
res.put("image_count",count);
return res;
}
}
|
3e092af90a930a6ef3818e46f335876dad0e1c3a | 5,610 | java | Java | src/main/java/io/datakitchen/ide/editors/neweditors/ContainerEditor.java | Carlos-Descalzi/dkide | cc767ddb90b658ff82badb2d2c26c3ebe76c857d | [
"Apache-2.0"
] | null | null | null | src/main/java/io/datakitchen/ide/editors/neweditors/ContainerEditor.java | Carlos-Descalzi/dkide | cc767ddb90b658ff82badb2d2c26c3ebe76c857d | [
"Apache-2.0"
] | null | null | null | src/main/java/io/datakitchen/ide/editors/neweditors/ContainerEditor.java | Carlos-Descalzi/dkide | cc767ddb90b658ff82badb2d2c26c3ebe76c857d | [
"Apache-2.0"
] | null | null | null | 29.067358 | 135 | 0.610517 | 3,875 | package io.datakitchen.ide.editors.neweditors;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import io.datakitchen.ide.editors.neweditors.container.*;
import io.datakitchen.ide.editors.neweditors.palette.ModuleComponentSource;
import io.datakitchen.ide.model.*;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class ContainerEditor extends BaseSimpleEditor implements RunRequestHandler {
private ContainerModelImpl model;
private ModelWriteHandler writeHandler;
public ContainerEditor(Module module, VirtualFile notebookFile) {
super(module, notebookFile);
}
protected JComponent buildView(){
this.model = new ContainerModelImpl(module, notebookFile);
ContainerModelReader reader = new ContainerModelReader(notebookFile.getParent());
try {
reader.read(model, new ModuleComponentSource(module));
}catch (Exception ex){
ex.printStackTrace();
}
this.writeHandler = new ModelWriteHandler(module.getProject(), notebookFile.getParent(), model);
ContainerNodeView containerNodeView = new ContainerNodeView(model, new ModuleComponentSource(module));
containerNodeView.setRunRequestHandler(this);
return containerNodeView;
}
@Override
public void runConnection(Connection connection) {
if (model.getDataSources().getConnections().contains(connection)){
runDataSource(connection);
}
}
private void runDataSource(Connection connection) {
if (model.getDataSources().getConnections().contains(connection)){
runDataSource(connection);
}
}
private static class ModelWriteHandler implements ContainerModelListener, ConnectionListListener, ConnectionListener, KeyListener {
private final ContainerModelWriter writer;
private final VirtualFile nodeFolder;
public ModelWriteHandler(Project project, VirtualFile nodeFolder, ContainerModelImpl model){
this.nodeFolder = nodeFolder;
writer = new ContainerModelWriter(project, model);
model.addContainerModelListener(this);
model.getDataSources().addConnectionListListener(this);
for (Connection c:model.getDataSources().getConnections()){
c.addConnectionListener(this);
for (Key key:c.getKeys()){
key.addKeyListener(this);
}
}
model.getDataSinks().addConnectionListListener(this);
for (Connection c:model.getDataSinks().getConnections()){
c.addConnectionListener(this);
for (Key key:c.getKeys()){
key.addKeyListener(this);
}
}
}
private void save(){
try {
writer.write(nodeFolder);
}catch (Exception ex){
ex.printStackTrace();
}
}
@Override
public void connectionAdded(ConnectionListEvent event) {
event.getConnection().addConnectionListener(this);
save();
}
@Override
public void connectionRemoved(ConnectionListEvent event) {
event.getConnection().removeConnectionListener(this);
save();
}
@Override
public void nameChanged(ConnectionEvent event) {
save();
}
@Override
public void testAdded(ConnectionEvent event) {
save();
}
@Override
public void testChanged(ConnectionEvent event) {
save();
}
@Override
public void testRemoved(ConnectionEvent event) {
save();
}
@Override
public void variableAdded(ConnectionEvent event) {
save();
}
@Override
public void variableRemoved(ConnectionEvent event) {
save();
}
@Override
public void keyAdded(ConnectionEvent event) {
event.getKey().addKeyListener(this);
save();
}
@Override
public void keyRemoved(ConnectionEvent event) {
event.getKey().removeKeyListener(this);
save();
}
@Override
public void variableAdded(KeyEvent event) {
save();
}
@Override
public void variableRemoved(KeyEvent event) {
save();
}
@Override
public void keyChanged(KeyEvent event) {
save();
}
@Override
public void inputFilesAdded(ContainerModelEvent event) {
save();
}
@Override
public void inputFilesRemoved(ContainerModelEvent event) {
save();
}
@Override
public void variableAssignmentAdded(ContainerModelEvent event) {
save();
}
@Override
public void variableAssignmentRemoved(ContainerModelEvent event) {
save();
}
@Override
public void nodePropertyChanged(ContainerModelEvent event) {
save();
}
@Override
public void inputFileRenamed(ContainerModelEvent containerModelEvent) {
save();
}
}
@Override
public @Nls(capitalization = Nls.Capitalization.Title) @NotNull String getName() {
return "Container Node "+notebookFile.getParent().getName();
}
}
|
3e092b0cd3d5f255384d21264f26ef5366c9ca8d | 709 | java | Java | src/test/java/org/hazelcast/protocol/RoboTrackProtocolDecoderTest.java | 7erry/iot | 90ee5be1e5ba594ac202659e1cddfb755c333ea1 | [
"Apache-2.0"
] | null | null | null | src/test/java/org/hazelcast/protocol/RoboTrackProtocolDecoderTest.java | 7erry/iot | 90ee5be1e5ba594ac202659e1cddfb755c333ea1 | [
"Apache-2.0"
] | null | null | null | src/test/java/org/hazelcast/protocol/RoboTrackProtocolDecoderTest.java | 7erry/iot | 90ee5be1e5ba594ac202659e1cddfb755c333ea1 | [
"Apache-2.0"
] | 1 | 2021-12-16T08:44:40.000Z | 2021-12-16T08:44:40.000Z | 29 | 159 | 0.751724 | 3,876 | package org.hazelcast.protocol;
import org.junit.Test;
import org.hazelcast.ProtocolTest;
public class RoboTrackProtocolDecoderTest extends ProtocolTest {
@Test
public void testDecode() throws Exception {
RoboTrackProtocolDecoder decoder = new RoboTrackProtocolDecoder(null);
verifyNull(decoder, binary(
"00524f424f545241434b00000000000000383638323034303032323533343136313233343536373839303132312e313261000000312e353761000000312e3030000000003e"));
verifyPosition(decoder, binary(
"03e020bb5a034409034862120210a9e105000000000000b9"));
verifyPosition(decoder, binary(
"vqbpgud2ghvjgm1n5hdgjnn5818fzsf2"));
}
}
|
3e092c172d8556dc8283b49031badb5a00b580f0 | 842 | java | Java | src/main/java/pl/art/lach/mateusz/javaopenchess/core/data_transfer/TransferFormat.java | AmrishJhaveri/Virtual-Appliance-Unikernel_OS-Containers-AWS | 962b28e091391e6f1f3ee03b324306c91303281b | [
"MIT"
] | null | null | null | src/main/java/pl/art/lach/mateusz/javaopenchess/core/data_transfer/TransferFormat.java | AmrishJhaveri/Virtual-Appliance-Unikernel_OS-Containers-AWS | 962b28e091391e6f1f3ee03b324306c91303281b | [
"MIT"
] | null | null | null | src/main/java/pl/art/lach/mateusz/javaopenchess/core/data_transfer/TransferFormat.java | AmrishJhaveri/Virtual-Appliance-Unikernel_OS-Containers-AWS | 962b28e091391e6f1f3ee03b324306c91303281b | [
"MIT"
] | null | null | null | 32.384615 | 74 | 0.716152 | 3,877 | /*
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package pl.art.lach.mateusz.javaopenchess.core.data_transfer;
/**
* @author Mateusz Slawomir Lach (matlak, msl)
*/
public enum TransferFormat
{
PGN,
FEN
}
|
3e092d1410d28449c3df0a70a57cba18691c7d82 | 3,420 | java | Java | cm-schema/src/test/java/com/cloudera/csd/validation/monitoring/constraints/EntityNamePrefixedWithServiceNameValidatorTest.java | JLLeitschuh/cm_ext | 90d8785c3bfcf819012159dffaa4af74faa5da9e | [
"Apache-2.0"
] | 173 | 2015-01-12T08:33:06.000Z | 2022-03-25T09:23:37.000Z | cm-schema/src/test/java/com/cloudera/csd/validation/monitoring/constraints/EntityNamePrefixedWithServiceNameValidatorTest.java | JLLeitschuh/cm_ext | 90d8785c3bfcf819012159dffaa4af74faa5da9e | [
"Apache-2.0"
] | 30 | 2015-02-27T03:45:38.000Z | 2021-04-20T03:46:24.000Z | cm-schema/src/test/java/com/cloudera/csd/validation/monitoring/constraints/EntityNamePrefixedWithServiceNameValidatorTest.java | JLLeitschuh/cm_ext | 90d8785c3bfcf819012159dffaa4af74faa5da9e | [
"Apache-2.0"
] | 111 | 2015-04-19T01:06:52.000Z | 2022-03-30T23:44:57.000Z | 38.426966 | 75 | 0.752339 | 3,878 | // Licensed to Cloudera, Inc. under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. Cloudera, Inc. 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.cloudera.csd.validation.monitoring.constraints;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import com.cloudera.csd.descriptors.MetricEntityTypeDescriptor;
import com.cloudera.csd.validation.monitoring.MonitoringValidationContext;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import java.util.List;
import javax.validation.ConstraintViolation;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class EntityNamePrefixedWithServiceNameValidatorTest
extends AbstractMonitoringValidatorBaseTest {
private EntityNamePrefixedWithServiceNameValidator validator;
private MonitoringValidationContext context;
@Before
public void setupEntityNamePrefixedWithServiceNameValidator() {
validator = new EntityNamePrefixedWithServiceNameValidator(
ImmutableSet.of("BUILT_IN_TYPE"));
context = new MonitoringValidationContext(serviceDescriptor);
}
@Test
public void testValidEntity() {
MetricEntityTypeDescriptor entity = mockEntity("FOOBAR_ENTITY_ONE");
assertTrue(validator.validate(context, entity, root).isEmpty());
}
@Test
public void testEmptyName() {
MetricEntityTypeDescriptor entity = mockEntity("");
List<ConstraintViolation<Object>> validations =
validator.validate(context, entity, root);
assertFalse(validations.isEmpty());
ConstraintViolation<Object> validation = Iterables.getOnlyElement(
validations);
assertTrue(validation.toString(),
validation.getMessage().contains(
"does not start with the service name"));
String path = validation.getPropertyPath().toString();
Assert.assertEquals(String.format("%s.name", SERVICE_NAME), path);
}
@Test
public void testInvaidEntityNotPrefixed() {
MetricEntityTypeDescriptor entity = mockEntity("FOO");
List<ConstraintViolation<Object>> validations =
validator.validate(context, entity, root);
assertFalse(validations.isEmpty());
ConstraintViolation<Object> validation = Iterables.getOnlyElement(
validations);
assertTrue(validation.toString(),
validation.getMessage().contains(
"Entity 'FOO' does not start with the service name"));
String path = validation.getPropertyPath().toString();
Assert.assertEquals(String.format("%s.name", SERVICE_NAME), path);
}
@Test
public void testBuiltInType() {
MetricEntityTypeDescriptor entity = mockEntity("BUILT_IN_TYPE");
assertTrue(validator.validate(context, entity, root).isEmpty());
}
}
|
3e092d50d5f8ec2852c0f08da2653db5560536ce | 2,171 | java | Java | spring-cloud/spring-cloud-master/00-zuul-fallback-9000/src/main/java/com/abc/fallback/ConsumerFallback.java | IThawk/learnCode | 0ac843d28b193eaab33fb33692f18361d71c7331 | [
"MIT"
] | 1 | 2020-12-26T04:52:15.000Z | 2020-12-26T04:52:15.000Z | spring-cloud/spring-cloud-master/00-zuul-fallback-9000/src/main/java/com/abc/fallback/ConsumerFallback.java | IThawk/learnCode | 0ac843d28b193eaab33fb33692f18361d71c7331 | [
"MIT"
] | 1 | 2020-12-26T04:57:19.000Z | 2020-12-26T04:57:19.000Z | spring-cloud/spring-cloud-master/00-zuul-fallback-9000/src/main/java/com/abc/fallback/ConsumerFallback.java | IThawk/learnCode | 0ac843d28b193eaab33fb33692f18361d71c7331 | [
"MIT"
] | 1 | 2021-12-06T01:13:18.000Z | 2021-12-06T01:13:18.000Z | 29.337838 | 79 | 0.607554 | 3,879 | package com.abc.fallback;
import org.springframework.cloud.netflix.zuul.filters.route.FallbackProvider;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.stereotype.Component;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@Component
public class ConsumerFallback implements FallbackProvider {
@Override
public String getRoute() {
// 对指定的微服务进行降级
// return "abcmsc-consumer-depart-8080";
// 指定对所有微服务进行降级
return "*";
}
/**
*
* @param route 请求中的微服务名称
* @param cause
* @return
*/
@Override
public ClientHttpResponse fallbackResponse(String route, Throwable cause) {
// 若微服务不是abcmsc-consumer-depart-8080,则不进行降级
// if (!"abcmsc-consumer-depart-8080".equals(route)) {
// return null;
// }
// 仅对abcmsc-consumer-depart-8080进行降级
return new ClientHttpResponse() {
@Override
public HttpHeaders getHeaders() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
return headers;
}
@Override
public InputStream getBody() throws IOException {
String msg = "fallback:" + route;
return new ByteArrayInputStream(msg.getBytes());
}
@Override
public HttpStatus getStatusCode() throws IOException {
return HttpStatus.SERVICE_UNAVAILABLE;
}
@Override
public int getRawStatusCode() throws IOException {
return HttpStatus.SERVICE_UNAVAILABLE.value();
}
@Override
public String getStatusText() throws IOException {
return HttpStatus.SERVICE_UNAVAILABLE.getReasonPhrase();
}
@Override
public void close() {
// 写资源释放代码
}
};
}
}
|
3e092e64a0a869a3ab03d07f30bdf768a38f4871 | 5,209 | java | Java | src/main/java/com/dynatrace/openkit/core/communication/BeaconSendingInitState.java | Dynatrace/openkit-java | 588ed890f02c84a38c88e59eb90b422ee85dcde7 | [
"Apache-2.0"
] | 28 | 2018-01-26T14:44:13.000Z | 2021-07-05T17:06:32.000Z | src/main/java/com/dynatrace/openkit/core/communication/BeaconSendingInitState.java | Dynatrace/openkit-java | 588ed890f02c84a38c88e59eb90b422ee85dcde7 | [
"Apache-2.0"
] | 9 | 2018-02-23T18:21:42.000Z | 2019-11-13T09:45:02.000Z | src/main/java/com/dynatrace/openkit/core/communication/BeaconSendingInitState.java | Dynatrace/openkit-java | 588ed890f02c84a38c88e59eb90b422ee85dcde7 | [
"Apache-2.0"
] | 36 | 2018-01-25T09:40:54.000Z | 2022-02-13T19:41:49.000Z | 36.683099 | 156 | 0.690152 | 3,880 | /**
* Copyright 2018-2021 Dynatrace 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.dynatrace.openkit.core.communication;
import com.dynatrace.openkit.protocol.StatusResponse;
import java.util.concurrent.TimeUnit;
/**
* Initial state for beacon sending.
*
* <p>
* The initial state is used to retrieve the configuration from the server and update the configuration.
* </p>
*
* <p>
* Transition to:
* <ul>
* <li>{@link BeaconSendingTerminalState} upon shutdown request</li>
* <li>{@link BeaconSendingCaptureOnState} if initial status request succeeded and capturing is enabled.</li>
* <li>{@link BeaconSendingCaptureOffState} if initial status request succeeded and capturing is disabled.</li>
* </ul>
* </p>
*/
class BeaconSendingInitState extends AbstractBeaconSendingState {
/**
* Times to use as delay between consecutive re-executions of this state, when no state transition is performed.
*/
static final long[] REINIT_DELAY_MILLISECONDS = {
TimeUnit.MINUTES.toMillis(1),
TimeUnit.MINUTES.toMillis(5),
TimeUnit.MINUTES.toMillis(15),
TimeUnit.HOURS.toMillis(1),
TimeUnit.HOURS.toMillis(2),
};
/**
* Maximum number of retries
*/
private static final int MAX_INITIAL_STATUS_REQUEST_RETRIES = 5;
static final long INITIAL_RETRY_SLEEP_TIME_MILLISECONDS = TimeUnit.SECONDS.toMillis(1);
/**
* Index to re-initialize delays.
*/
private int reinitializeDelayIndex = 0;
BeaconSendingInitState() {
super(false);
}
@Override
void doExecute(BeaconSendingContext context) throws InterruptedException {
// execute the status request until we get a response
StatusResponse statusResponse = executeStatusRequest(context);
if (context.isShutdownRequested()) {
// shutdown was requested -> abort init with failure
// transition to shutdown state is handled by base class
context.initCompleted(false);
} else if (BeaconSendingResponseUtil.isSuccessfulResponse(statusResponse)) {
// success -> continue with capture on/off depending on context
context.handleStatusResponse(statusResponse);
context.setNextState(context.isCaptureOn()
? new BeaconSendingCaptureOnState()
: new BeaconSendingCaptureOffState());
context.initCompleted(true);
}
}
@Override
AbstractBeaconSendingState getShutdownState() {
return new BeaconSendingTerminalState();
}
@Override
void onInterrupted(BeaconSendingContext context) {
context.initCompleted(false);
}
@Override
public String toString() {
return "Initial";
}
/**
* Execute status requests, until a successful response was received or shutdown was requested.
*
* @param context The state's context
* @return The last received status response, which might be erroneous if shutdown has been requested.
*
* @throws InterruptedException Thrown if the current thread has been interrupted.
*/
private StatusResponse executeStatusRequest(BeaconSendingContext context) throws InterruptedException {
StatusResponse statusResponse;
while (true) {
long currentTimestamp = context.getCurrentTimestamp();
context.setLastOpenSessionBeaconSendTime(currentTimestamp);
context.setLastStatusCheckTime(currentTimestamp);
statusResponse = BeaconSendingRequestUtil.sendStatusRequest(context, MAX_INITIAL_STATUS_REQUEST_RETRIES, INITIAL_RETRY_SLEEP_TIME_MILLISECONDS);
if (context.isShutdownRequested() || BeaconSendingResponseUtil.isSuccessfulResponse(statusResponse)) {
// shutdown was requested or a successful status response was received
break;
}
long sleepTime = REINIT_DELAY_MILLISECONDS[reinitializeDelayIndex];
if (BeaconSendingResponseUtil.isTooManyRequestsResponse(statusResponse)) {
// in case of too many requests the server might send us a retry-after
sleepTime = statusResponse.getRetryAfterInMilliseconds();
// also temporarily disable capturing to avoid further server overloading
context.disableCaptureAndClear();
}
// status request needs to be sent again after some delay
context.sleep(sleepTime);
reinitializeDelayIndex = Math.min(reinitializeDelayIndex + 1, REINIT_DELAY_MILLISECONDS.length - 1); // ensure no out of bounds
}
return statusResponse;
}
} |
3e092e7260118dc5c47c2c4658a39a25fad5549a | 2,284 | java | Java | sdk/resourcemanager/azure-resourcemanager-appplatform/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppDomainImpl.java | yiliuTo/azure-sdk-for-java | 4536b6e99ded1b2b77f79bc2c31f42566c97b704 | [
"MIT"
] | 1,350 | 2015-01-17T05:22:05.000Z | 2022-03-29T21:00:37.000Z | sdk/resourcemanager/azure-resourcemanager-appplatform/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppDomainImpl.java | yiliuTo/azure-sdk-for-java | 4536b6e99ded1b2b77f79bc2c31f42566c97b704 | [
"MIT"
] | 16,834 | 2015-01-07T02:19:09.000Z | 2022-03-31T23:29:10.000Z | sdk/resourcemanager/azure-resourcemanager-appplatform/src/main/java/com/azure/resourcemanager/appplatform/implementation/SpringAppDomainImpl.java | yiliuTo/azure-sdk-for-java | 4536b6e99ded1b2b77f79bc2c31f42566c97b704 | [
"MIT"
] | 1,586 | 2015-01-02T01:50:28.000Z | 2022-03-31T11:25:34.000Z | 35.138462 | 114 | 0.700963 | 3,881 | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.resourcemanager.appplatform.implementation;
import com.azure.resourcemanager.appplatform.AppPlatformManager;
import com.azure.resourcemanager.appplatform.fluent.models.CustomDomainResourceInner;
import com.azure.resourcemanager.appplatform.models.CustomDomainProperties;
import com.azure.resourcemanager.appplatform.models.SpringApp;
import com.azure.resourcemanager.appplatform.models.SpringAppDomain;
import com.azure.resourcemanager.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl;
import reactor.core.publisher.Mono;
public class SpringAppDomainImpl
extends ExternalChildResourceImpl<SpringAppDomain, CustomDomainResourceInner, SpringAppImpl, SpringApp>
implements SpringAppDomain {
SpringAppDomainImpl(String name, SpringAppImpl parent, CustomDomainResourceInner innerObject) {
super(name, parent, innerObject);
}
@Override
public Mono<SpringAppDomain> createResourceAsync() {
return manager().serviceClient().getCustomDomains().createOrUpdateAsync(
parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name(), properties()
)
.map(inner -> {
setInner(inner);
return this;
});
}
@Override
public Mono<SpringAppDomain> updateResourceAsync() {
return createResourceAsync();
}
@Override
public Mono<Void> deleteResourceAsync() {
return manager().serviceClient().getBindings().deleteAsync(
parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name()
);
}
@Override
protected Mono<CustomDomainResourceInner> getInnerAsync() {
return manager().serviceClient().getCustomDomains().getAsync(
parent().parent().resourceGroupName(), parent().parent().name(), parent().name(), name()
);
}
@Override
public String id() {
return innerModel().id();
}
@Override
public CustomDomainProperties properties() {
return innerModel().properties();
}
private AppPlatformManager manager() {
return parent().manager();
}
}
|
3e092f008a0ed73ff88cebe194cf67c067088c04 | 505 | java | Java | Java/Java Advanced/Defining classes/Exercise/src/FamilyTree/Person.java | galin-kostadinov/Software-Engineering | 55189648d787b35f1e9cd24cc4449c6beda51c90 | [
"MIT"
] | 1 | 2019-07-21T13:00:31.000Z | 2019-07-21T13:00:31.000Z | Java/Java Advanced/Defining classes/Exercise/src/FamilyTree/Person.java | galin-kostadinov/Software-Engineering | 55189648d787b35f1e9cd24cc4449c6beda51c90 | [
"MIT"
] | null | null | null | Java/Java Advanced/Defining classes/Exercise/src/FamilyTree/Person.java | galin-kostadinov/Software-Engineering | 55189648d787b35f1e9cd24cc4449c6beda51c90 | [
"MIT"
] | null | null | null | 17.413793 | 49 | 0.605941 | 3,882 | package FamilyTree;
public class Person {
private String name;
private String birthday;
public String getName() {
return name;
}
public String getBirthday() {
return birthday;
}
public Person(String name, String birthday) {
this.setName(name);
this.setBirthday(birthday);
}
public void setName(String name) {
this.name = name;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
}
|
3e092f66ff4727495c5233c39e8e88a85bf7b1e7 | 8,548 | java | Java | pocs/terraform-cdk-fun/src/main/java/imports/kubernetes/IngressSpec.java | ladybug/java-pocs | 6aa683dc5b0c3cc6fb9695713bac73d38aca53fd | [
"Unlicense"
] | 36 | 2019-08-29T12:24:31.000Z | 2022-03-31T13:25:58.000Z | pocs/terraform-cdk-fun/src/main/java/imports/kubernetes/IngressSpec.java | ladybug/java-pocs | 6aa683dc5b0c3cc6fb9695713bac73d38aca53fd | [
"Unlicense"
] | 68 | 2020-06-23T16:34:50.000Z | 2022-03-23T07:24:09.000Z | pocs/terraform-cdk-fun/src/main/java/imports/kubernetes/IngressSpec.java | ladybug/java-pocs | 6aa683dc5b0c3cc6fb9695713bac73d38aca53fd | [
"Unlicense"
] | 30 | 2018-04-06T22:08:22.000Z | 2022-03-31T17:57:24.000Z | 45.227513 | 253 | 0.642255 | 3,883 | package imports.kubernetes;
@javax.annotation.Generated(value = "jsii-pacmak/1.30.0 (build adae23f)", date = "2021-06-16T06:12:12.605Z")
@software.amazon.jsii.Jsii(module = imports.kubernetes.$Module.class, fqn = "kubernetes.IngressSpec")
@software.amazon.jsii.Jsii.Proxy(IngressSpec.Jsii$Proxy.class)
public interface IngressSpec extends software.amazon.jsii.JsiiSerializable {
/**
* backend block.
* <p>
* Docs at Terraform Registry: {@link https://www.terraform.io/docs/providers/kubernetes/r/ingress.html#backend Ingress#backend}
*/
default @org.jetbrains.annotations.Nullable java.util.List<imports.kubernetes.IngressSpecBackend> getBackend() {
return null;
}
/**
* rule block.
* <p>
* Docs at Terraform Registry: {@link https://www.terraform.io/docs/providers/kubernetes/r/ingress.html#rule Ingress#rule}
*/
default @org.jetbrains.annotations.Nullable java.util.List<imports.kubernetes.IngressSpecRule> getRule() {
return null;
}
/**
* tls block.
* <p>
* Docs at Terraform Registry: {@link https://www.terraform.io/docs/providers/kubernetes/r/ingress.html#tls Ingress#tls}
*/
default @org.jetbrains.annotations.Nullable java.util.List<imports.kubernetes.IngressSpecTls> getTls() {
return null;
}
/**
* @return a {@link Builder} of {@link IngressSpec}
*/
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link IngressSpec}
*/
public static final class Builder implements software.amazon.jsii.Builder<IngressSpec> {
private java.util.List<imports.kubernetes.IngressSpecBackend> backend;
private java.util.List<imports.kubernetes.IngressSpecRule> rule;
private java.util.List<imports.kubernetes.IngressSpecTls> tls;
/**
* Sets the value of {@link IngressSpec#getBackend}
* @param backend backend block.
* Docs at Terraform Registry: {@link https://www.terraform.io/docs/providers/kubernetes/r/ingress.html#backend Ingress#backend}
* @return {@code this}
*/
@SuppressWarnings("unchecked")
public Builder backend(java.util.List<? extends imports.kubernetes.IngressSpecBackend> backend) {
this.backend = (java.util.List<imports.kubernetes.IngressSpecBackend>)backend;
return this;
}
/**
* Sets the value of {@link IngressSpec#getRule}
* @param rule rule block.
* Docs at Terraform Registry: {@link https://www.terraform.io/docs/providers/kubernetes/r/ingress.html#rule Ingress#rule}
* @return {@code this}
*/
@SuppressWarnings("unchecked")
public Builder rule(java.util.List<? extends imports.kubernetes.IngressSpecRule> rule) {
this.rule = (java.util.List<imports.kubernetes.IngressSpecRule>)rule;
return this;
}
/**
* Sets the value of {@link IngressSpec#getTls}
* @param tls tls block.
* Docs at Terraform Registry: {@link https://www.terraform.io/docs/providers/kubernetes/r/ingress.html#tls Ingress#tls}
* @return {@code this}
*/
@SuppressWarnings("unchecked")
public Builder tls(java.util.List<? extends imports.kubernetes.IngressSpecTls> tls) {
this.tls = (java.util.List<imports.kubernetes.IngressSpecTls>)tls;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link IngressSpec}
* @throws NullPointerException if any required attribute was not provided
*/
@Override
public IngressSpec build() {
return new Jsii$Proxy(backend, rule, tls);
}
}
/**
* An implementation for {@link IngressSpec}
*/
@software.amazon.jsii.Internal
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements IngressSpec {
private final java.util.List<imports.kubernetes.IngressSpecBackend> backend;
private final java.util.List<imports.kubernetes.IngressSpecRule> rule;
private final java.util.List<imports.kubernetes.IngressSpecTls> tls;
/**
* Constructor that initializes the object based on values retrieved from the JsiiObject.
* @param objRef Reference to the JSII managed object.
*/
protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
this.backend = software.amazon.jsii.Kernel.get(this, "backend", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(imports.kubernetes.IngressSpecBackend.class)));
this.rule = software.amazon.jsii.Kernel.get(this, "rule", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(imports.kubernetes.IngressSpecRule.class)));
this.tls = software.amazon.jsii.Kernel.get(this, "tls", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(imports.kubernetes.IngressSpecTls.class)));
}
/**
* Constructor that initializes the object based on literal property values passed by the {@link Builder}.
*/
@SuppressWarnings("unchecked")
protected Jsii$Proxy(final java.util.List<? extends imports.kubernetes.IngressSpecBackend> backend, final java.util.List<? extends imports.kubernetes.IngressSpecRule> rule, final java.util.List<? extends imports.kubernetes.IngressSpecTls> tls) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
this.backend = (java.util.List<imports.kubernetes.IngressSpecBackend>)backend;
this.rule = (java.util.List<imports.kubernetes.IngressSpecRule>)rule;
this.tls = (java.util.List<imports.kubernetes.IngressSpecTls>)tls;
}
@Override
public final java.util.List<imports.kubernetes.IngressSpecBackend> getBackend() {
return this.backend;
}
@Override
public final java.util.List<imports.kubernetes.IngressSpecRule> getRule() {
return this.rule;
}
@Override
public final java.util.List<imports.kubernetes.IngressSpecTls> getTls() {
return this.tls;
}
@Override
@software.amazon.jsii.Internal
public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() {
final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE;
final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
if (this.getBackend() != null) {
data.set("backend", om.valueToTree(this.getBackend()));
}
if (this.getRule() != null) {
data.set("rule", om.valueToTree(this.getRule()));
}
if (this.getTls() != null) {
data.set("tls", om.valueToTree(this.getTls()));
}
final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
struct.set("fqn", om.valueToTree("kubernetes.IngressSpec"));
struct.set("data", data);
final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
obj.set("$jsii.struct", struct);
return obj;
}
@Override
public final boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
IngressSpec.Jsii$Proxy that = (IngressSpec.Jsii$Proxy) o;
if (this.backend != null ? !this.backend.equals(that.backend) : that.backend != null) return false;
if (this.rule != null ? !this.rule.equals(that.rule) : that.rule != null) return false;
return this.tls != null ? this.tls.equals(that.tls) : that.tls == null;
}
@Override
public final int hashCode() {
int result = this.backend != null ? this.backend.hashCode() : 0;
result = 31 * result + (this.rule != null ? this.rule.hashCode() : 0);
result = 31 * result + (this.tls != null ? this.tls.hashCode() : 0);
return result;
}
}
}
|
3e093082d193b52b84aa4eed07bd596105aa2ffa | 1,036 | java | Java | Mage.Sets/src/mage/cards/c/CentaurSafeguard.java | dsenginr/mage | 94e9aeedc20dcb74264e58fd198f46215828ef5c | [
"MIT"
] | 1,444 | 2015-01-02T00:25:38.000Z | 2022-03-31T13:57:18.000Z | Mage.Sets/src/mage/cards/c/CentaurSafeguard.java | dsenginr/mage | 94e9aeedc20dcb74264e58fd198f46215828ef5c | [
"MIT"
] | 6,180 | 2015-01-02T19:10:09.000Z | 2022-03-31T21:10:44.000Z | Mage.Sets/src/mage/cards/c/CentaurSafeguard.java | dsenginr/mage | 94e9aeedc20dcb74264e58fd198f46215828ef5c | [
"MIT"
] | 1,001 | 2015-01-01T01:15:20.000Z | 2022-03-30T20:23:04.000Z | 25.9 | 85 | 0.706564 | 3,884 |
package mage.cards.c;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.DiesSourceTriggeredAbility;
import mage.abilities.effects.common.GainLifeEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
/**
*
* @author Loki
*/
public final class CentaurSafeguard extends CardImpl {
public CentaurSafeguard(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G/W}");
this.subtype.add(SubType.CENTAUR);
this.subtype.add(SubType.WARRIOR);
this.power = new MageInt(3);
this.toughness = new MageInt(1);
// When Centaur Safeguard dies, you may gain 3 life.
this.addAbility(new DiesSourceTriggeredAbility(new GainLifeEffect(3), true));
}
private CentaurSafeguard(final CentaurSafeguard card) {
super(card);
}
@Override
public CentaurSafeguard copy() {
return new CentaurSafeguard(this);
}
}
|
3e0930ade286864817c88ca4f674d5f4749d0f44 | 4,940 | java | Java | graphsdk/src/main/java/com/microsoft/graph/generated/BaseEducationRoot.java | SailReal/msgraph-sdk-android | 68bf5bf437e8688142493de5faf88154c388d7c8 | [
"MIT"
] | 61 | 2016-06-11T20:14:35.000Z | 2021-06-09T03:47:07.000Z | graphsdk/src/main/java/com/microsoft/graph/generated/BaseEducationRoot.java | SailReal/msgraph-sdk-android | 68bf5bf437e8688142493de5faf88154c388d7c8 | [
"MIT"
] | 95 | 2016-03-30T22:16:20.000Z | 2020-09-03T18:37:43.000Z | graphsdk/src/main/java/com/microsoft/graph/generated/BaseEducationRoot.java | SailReal/msgraph-sdk-android | 68bf5bf437e8688142493de5faf88154c388d7c8 | [
"MIT"
] | 49 | 2016-03-30T19:52:31.000Z | 2022-02-25T11:04:50.000Z | 34.248276 | 152 | 0.620016 | 3,885 | // ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------
package com.microsoft.graph.generated;
import com.microsoft.graph.concurrency.*;
import com.microsoft.graph.core.*;
import com.microsoft.graph.extensions.*;
import com.microsoft.graph.http.*;
import com.microsoft.graph.generated.*;
import com.microsoft.graph.options.*;
import com.microsoft.graph.serializer.*;
import java.util.Arrays;
import java.util.EnumSet;
import com.google.gson.JsonObject;
import com.google.gson.JsonElement;
import com.google.gson.annotations.*;
import java.util.HashMap;
import java.util.Map;
// **NOTE** This file was generated by a tool and any changes will be overwritten.
/**
* The class for the Base Education Root.
*/
public class BaseEducationRoot extends Entity implements IJsonBackedObject {
/**
* The Classes.
*
*/
public transient EducationClassCollectionPage classes;
/**
* The Schools.
*
*/
public transient EducationSchoolCollectionPage schools;
/**
* The Users.
*
*/
public transient EducationUserCollectionPage users;
/**
* The Me.
*
*/
@SerializedName("me")
@Expose
public EducationUser me;
/**
* The raw representation of this class
*/
private transient JsonObject mRawObject;
/**
* The serializer
*/
private transient ISerializer mSerializer;
/**
* Gets the raw representation of this class
* @return the raw representation of this class
*/
public JsonObject getRawObject() {
return mRawObject;
}
/**
* Gets serializer
* @return the serializer
*/
protected ISerializer getSerializer() {
return mSerializer;
}
/**
* Sets the raw json object
*
* @param serializer The serializer
* @param json The json object to set this object to
*/
public void setRawObject(final ISerializer serializer, final JsonObject json) {
mSerializer = serializer;
mRawObject = json;
if (json.has("classes")) {
final BaseEducationClassCollectionResponse response = new BaseEducationClassCollectionResponse();
if (json.has("dycjh@example.com")) {
response.nextLink = json.get("dycjh@example.com").getAsString();
}
final JsonObject[] sourceArray = serializer.deserializeObject(json.get("classes").toString(), JsonObject[].class);
final EducationClass[] array = new EducationClass[sourceArray.length];
for (int i = 0; i < sourceArray.length; i++) {
array[i] = serializer.deserializeObject(sourceArray[i].toString(), EducationClass.class);
array[i].setRawObject(serializer, sourceArray[i]);
}
response.value = Arrays.asList(array);
classes = new EducationClassCollectionPage(response, null);
}
if (json.has("schools")) {
final BaseEducationSchoolCollectionResponse response = new BaseEducationSchoolCollectionResponse();
if (json.has("anpch@example.com")) {
response.nextLink = json.get("anpch@example.com").getAsString();
}
final JsonObject[] sourceArray = serializer.deserializeObject(json.get("schools").toString(), JsonObject[].class);
final EducationSchool[] array = new EducationSchool[sourceArray.length];
for (int i = 0; i < sourceArray.length; i++) {
array[i] = serializer.deserializeObject(sourceArray[i].toString(), EducationSchool.class);
array[i].setRawObject(serializer, sourceArray[i]);
}
response.value = Arrays.asList(array);
schools = new EducationSchoolCollectionPage(response, null);
}
if (json.has("users")) {
final BaseEducationUserCollectionResponse response = new BaseEducationUserCollectionResponse();
if (json.has("upchh@example.com")) {
response.nextLink = json.get("upchh@example.com").getAsString();
}
final JsonObject[] sourceArray = serializer.deserializeObject(json.get("users").toString(), JsonObject[].class);
final EducationUser[] array = new EducationUser[sourceArray.length];
for (int i = 0; i < sourceArray.length; i++) {
array[i] = serializer.deserializeObject(sourceArray[i].toString(), EducationUser.class);
array[i].setRawObject(serializer, sourceArray[i]);
}
response.value = Arrays.asList(array);
users = new EducationUserCollectionPage(response, null);
}
}
}
|
3e0930e1a034db6d4439f61e55f46ebf22ca9529 | 2,008 | java | Java | solvers/java/src/test/java/com/analog/lyric/dimple/test/dummySolver/DummyRealVariable.java | yujianyuanhaha/Co-Channel-Sig-Detection | 5c6b4d203957fb043966ff17a2241555cf03e5fe | [
"Apache-2.0"
] | 1 | 2020-04-29T12:49:17.000Z | 2020-04-29T12:49:17.000Z | solvers/java/src/test/java/com/analog/lyric/dimple/test/dummySolver/DummyRealVariable.java | yujianyuanhaha/Co-Channel-Sig-Detection | 5c6b4d203957fb043966ff17a2241555cf03e5fe | [
"Apache-2.0"
] | null | null | null | solvers/java/src/test/java/com/analog/lyric/dimple/test/dummySolver/DummyRealVariable.java | yujianyuanhaha/Co-Channel-Sig-Detection | 5c6b4d203957fb043966ff17a2241555cf03e5fe | [
"Apache-2.0"
] | 1 | 2020-04-29T12:49:19.000Z | 2020-04-29T12:49:19.000Z | 23.904762 | 109 | 0.696215 | 3,886 | /*******************************************************************************
* Copyright 2014 Analog Devices, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/
package com.analog.lyric.dimple.test.dummySolver;
import com.analog.lyric.dimple.model.variables.Real;
import com.analog.lyric.dimple.solvers.core.SRealVariableBase;
import com.analog.lyric.dimple.solvers.interfaces.ISolverFactor;
import com.analog.lyric.dimple.solvers.interfaces.ISolverNode;
import org.eclipse.jdt.annotation.Nullable;
public class DummyRealVariable extends SRealVariableBase
{
public DummyRealVariable(Real var)
{
super(var);
}
@Override
public void setInputOrFixedValue(@Nullable Object input, @Nullable Object fixedValue, boolean hasFixedValue)
{
}
@Override
public @Nullable Object getBelief()
{
return null;
}
@Override
public @Nullable Object[] createMessages(ISolverFactor factor)
{
return null;
}
@Override
public @Nullable Object resetInputMessage(Object message)
{
return null;
}
@Override
protected void doUpdateEdge(int outPortNum)
{
}
@Override
public void resetEdgeMessages(int portNum)
{
}
@Override
public @Nullable Object getInputMsg(int portIndex)
{
return null;
}
@Override
public @Nullable Object getOutputMsg(int portIndex)
{
return null;
}
@Override
public void moveMessages(ISolverNode other, int thisPortNum, int otherPortNum)
{
}
}
|
3e0931a21748b5d07af953c0fcd0b714921126e5 | 2,173 | java | Java | my-app/src/test/java/org/gradle/test/performance/mediummonolithicjavaproject/p70/Test1418.java | oehme/analysing-gradle-performance | 9f362b7d488dc0547a4443927d7c47a4b3fd3eec | [
"Apache-2.0"
] | 1 | 2017-08-30T17:59:45.000Z | 2017-08-30T17:59:45.000Z | my-app/src/test/java/org/gradle/test/performance/mediummonolithicjavaproject/p70/Test1418.java | oehme/analysing-gradle-performance | 9f362b7d488dc0547a4443927d7c47a4b3fd3eec | [
"Apache-2.0"
] | null | null | null | my-app/src/test/java/org/gradle/test/performance/mediummonolithicjavaproject/p70/Test1418.java | oehme/analysing-gradle-performance | 9f362b7d488dc0547a4443927d7c47a4b3fd3eec | [
"Apache-2.0"
] | 1 | 2019-03-18T18:52:45.000Z | 2019-03-18T18:52:45.000Z | 27.506329 | 68 | 0.653474 | 3,887 | package org.gradle.test.performance.mediummonolithicjavaproject.p70;
import org.junit.Test;
import static org.junit.Assert.*;
public class Test1418 {
Production1418 objectUnderTest = new Production1418();
@Test
public void testProperty0() {
Production1415 value = new Production1415();
objectUnderTest.setProperty0(value);
assertEquals(value, objectUnderTest.getProperty0());
}
@Test
public void testProperty1() {
Production1416 value = new Production1416();
objectUnderTest.setProperty1(value);
assertEquals(value, objectUnderTest.getProperty1());
}
@Test
public void testProperty2() {
Production1417 value = new Production1417();
objectUnderTest.setProperty2(value);
assertEquals(value, objectUnderTest.getProperty2());
}
@Test
public void testProperty3() {
String value = "value";
objectUnderTest.setProperty3(value);
assertEquals(value, objectUnderTest.getProperty3());
}
@Test
public void testProperty4() {
String value = "value";
objectUnderTest.setProperty4(value);
assertEquals(value, objectUnderTest.getProperty4());
}
@Test
public void testProperty5() {
String value = "value";
objectUnderTest.setProperty5(value);
assertEquals(value, objectUnderTest.getProperty5());
}
@Test
public void testProperty6() {
String value = "value";
objectUnderTest.setProperty6(value);
assertEquals(value, objectUnderTest.getProperty6());
}
@Test
public void testProperty7() {
String value = "value";
objectUnderTest.setProperty7(value);
assertEquals(value, objectUnderTest.getProperty7());
}
@Test
public void testProperty8() {
String value = "value";
objectUnderTest.setProperty8(value);
assertEquals(value, objectUnderTest.getProperty8());
}
@Test
public void testProperty9() {
String value = "value";
objectUnderTest.setProperty9(value);
assertEquals(value, objectUnderTest.getProperty9());
}
} |
3e0932040915da2a07490ede9d580799323a0d16 | 3,618 | java | Java | src/after/ThreadsController.java | frandirianto/Snake | 7d9869e75933cefdac40fcc8cc5bbd256253511c | [
"MIT"
] | null | null | null | src/after/ThreadsController.java | frandirianto/Snake | 7d9869e75933cefdac40fcc8cc5bbd256253511c | [
"MIT"
] | null | null | null | src/after/ThreadsController.java | frandirianto/Snake | 7d9869e75933cefdac40fcc8cc5bbd256253511c | [
"MIT"
] | null | null | null | 24.780822 | 94 | 0.665561 | 3,888 | package after;
import java.util.ArrayList;
public class ThreadsController extends Thread {
ArrayList<ArrayList<DataOfSquare>> squares= new ArrayList<ArrayList<DataOfSquare>>();
Tuple headSnakePos;
int sizeSnake;
long speed;
public static int directionSnake;
ArrayList<Tuple> positions = new ArrayList<Tuple>();
Tuple foodPosition;
ThreadsController(Tuple positionDepart){
squares = Window.grid;
headSnakePos = new Tuple(positionDepart.getX(),positionDepart.getY());
directionSnake = 1;
Tuple headPosition = new Tuple(headSnakePos.getX(),headSnakePos.getY());
positions.add(headPosition);
foodPosition= new Tuple(Window.HEIGHT-1,Window.WIDTH-1);
spawnFood(foodPosition);
}
private void spawnFood(Tuple foodPositionIn){
squares.get(foodPositionIn.getX()).get(foodPositionIn.getY()).lightMeUp(1);
}
public void init(){
sizeSnake = 3;
speed = 50;
}
public void run() {
init();
while(true){
moveInternal();
checkCollision();
moveExternal();
deleteTail();
speed();
}
}
private void moveInternal(){
if(directionSnake == 1) changeMove(Math.abs(headSnakePos.getX()+1)%20, headSnakePos.getY());
else if(directionSnake == 2) {
if(headSnakePos.getX()-1 < 0) changeMove(19, headSnakePos.getY());
else changeMove(Math.abs(headSnakePos.getX()-1)%20, headSnakePos.getY());
}
else if(directionSnake == 3) {
if(headSnakePos.getY()-1 < 0) changeMove(headSnakePos.getX(), 19);
else changeMove(headSnakePos.getX(), Math.abs(headSnakePos.getY()-1)%20);
}
else if(directionSnake == 4) changeMove(headSnakePos.getX(), (headSnakePos.getY()+1)%20);
positions.add(new Tuple(headSnakePos.getX(), headSnakePos.getY()));
}
private void changeMove(int x, int y) {
headSnakePos.changeData(x, y);
}
private void moveExternal(){
for(Tuple t : positions){
int y = t.getX();
int x = t.getY();
squares.get(x).get(y).lightMeUp(0);
}
}
private void speed(){
try {
sleep(speed);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
private void checkCollision() {
Tuple posCritique = positions.get(positions.size()-1);
for(int i = 0; i<=positions.size()-2 ; i++){
bitSelf(posCritique, i);
}
eatFood(posCritique);
}
private void bitSelf(Tuple posCritique, int index) {
Tuple position = positions.get(index);
if(posCritique.getX() == position.getX() && posCritique.getY() == position.getY()){
stopTheGame();
}
}
private void eatFood(Tuple posCritique) {
if(posCritique.getX() == foodPosition.getY() && posCritique.getY() == foodPosition.getX()){
System.out.println("Yummy!");
sizeSnake += 1;
foodPosition = getValAleaNotInSnake();
spawnFood(foodPosition);
}
}
private void stopTheGame(){
System.out.println("COLISION! \n");
while(true){
speed();
}
}
private Tuple getValAleaNotInSnake(){
Tuple position = randomTuple();
for(int i = 0;i<=positions.size()-1;i++){
if(position.getY()==positions.get(i).getX() && position.getX()==positions.get(i).getY()){
position = randomTuple();
i=0;
}
}
return position;
}
private Tuple randomTuple() {
int ranX = (int) (Math.random()*19);
int ranY = (int) (Math.random()*19);
return new Tuple(ranX , ranY);
}
private void deleteTail(){
int size = sizeSnake;
for(int i = positions.size()-1; i>=0 ;i--){
if(size == 0){
Tuple position = positions.get(i);
squares.get(position.getY()).get(position.getX()).lightMeUp(2);
}
else size--;
}
size = sizeSnake;
for(int i = positions.size()-1 ; i >= 0 ;i--){
if(size == 0) positions.remove(i);
else size--;
}
}
}
|
3e093204c8edb5da881b8a8bfeb53cf3792f1342 | 2,191 | java | Java | src/main/java/com/srkw/tweakoni/block/JukeBoxHandler.java | strikerrocker/Tweakoni | 103b8563d9be51e6495ebf7aeeb5eb0091b7fe9b | [
"MIT"
] | 1 | 2018-03-29T20:08:10.000Z | 2018-03-29T20:08:10.000Z | src/main/java/com/srkw/tweakoni/block/JukeBoxHandler.java | strikerrocker/modoff | 103b8563d9be51e6495ebf7aeeb5eb0091b7fe9b | [
"MIT"
] | null | null | null | src/main/java/com/srkw/tweakoni/block/JukeBoxHandler.java | strikerrocker/modoff | 103b8563d9be51e6495ebf7aeeb5eb0091b7fe9b | [
"MIT"
] | null | null | null | 29.213333 | 112 | 0.63989 | 3,889 | package com.srkw.tweakoni.block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nonnull;
import static net.minecraft.block.BlockJukebox.TileEntityJukebox;
public class JukeBoxHandler implements IItemHandlerModifiable {
private TileEntityJukebox jukebox;
public JukeBoxHandler(TileEntityJukebox tileEntityJukebox) {
this.jukebox = tileEntityJukebox;
}
@Override
public void setStackInSlot(int slot, @Nonnull ItemStack stack) {
if (slot != 0) throw new IndexOutOfBoundsException();
if (jukebox != null && jukebox.getRecord().isEmpty()) {
jukebox.setRecord(stack);
}
}
@Override
public int getSlots() {
return 1;
}
@Nonnull
@Override
public ItemStack getStackInSlot(int slot) {
if (slot != 0) throw new IndexOutOfBoundsException();
return jukebox.getRecord();
}
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if (slot != 0) throw new IndexOutOfBoundsException();
if (stack.getItem() instanceof ItemRecord && getStackInSlot(slot).isEmpty()) {
if (!simulate) {
jukebox.setRecord(stack);
jukebox.getWorld().playEvent(null, 1010, jukebox.getPos(), Item.getIdFromItem(stack.getItem()));
}
return ItemStack.EMPTY;
}
return stack;
}
@Nonnull
@Override
public ItemStack extractItem(int slot, int amount, boolean simulate) {
if (slot != 0) throw new IndexOutOfBoundsException();
ItemStack stack = jukebox.getRecord();
if (!simulate) {
jukebox.setRecord(ItemStack.EMPTY);
jukebox.getWorld().playEvent(1010, jukebox.getPos(), 0);
jukebox.getWorld().playRecord(jukebox.getPos(), null);
}
return stack;
}
@Override
public int getSlotLimit(int slot) {
if (slot != 0) {
throw new IndexOutOfBoundsException();
}
return 1;
}
}
|
3e09325f78978631e01da863139a16b8708fe045 | 1,576 | java | Java | src/main/java/dev/jensderuiter/websk/skript/expression/LoopValue.java | Norbiros/websk | 2438159a238295773681315ac14454ae5c0f80d6 | [
"MIT"
] | 10 | 2021-09-07T07:48:42.000Z | 2022-02-05T07:45:08.000Z | src/main/java/dev/jensderuiter/websk/skript/expression/LoopValue.java | Norbiros/websk | 2438159a238295773681315ac14454ae5c0f80d6 | [
"MIT"
] | 25 | 2021-10-30T15:24:17.000Z | 2022-03-25T18:29:18.000Z | src/main/java/dev/jensderuiter/websk/skript/expression/LoopValue.java | Norbiros/websk | 2438159a238295773681315ac14454ae5c0f80d6 | [
"MIT"
] | 9 | 2021-10-30T15:27:39.000Z | 2021-12-13T20:55:22.000Z | 29.185185 | 146 | 0.694162 | 3,890 | package dev.jensderuiter.websk.skript.expression;
import ch.njol.skript.Skript;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import dev.jensderuiter.websk.skript.factory.ServerEvent;
import dev.jensderuiter.websk.skript.type.Request;
import dev.jensderuiter.websk.utils.adapter.SkriptAdapter;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class LoopValue extends SimpleExpression<Object> {
public static Object lastEntity;
static {
Skript.registerExpression(
LoopValue.class,
Object.class,
ExpressionType.SIMPLE,
"[the] loop( |-)entity"
);
}
@Override
protected Object @NotNull [] get(@NotNull Event event) {
return lastEntity == null ? new Object[0] : new Object[] {lastEntity};
}
@Override
public boolean isSingle() {
return true;
}
@Override
public @NotNull Class<?> getReturnType() {
return Object.class;
}
@Override
public @NotNull String toString(@Nullable Event event, boolean b) {
return "loop-value";
}
@Override
public boolean init(Expression<?> @NotNull [] expressions, int i, @NotNull Kleenean kleenean, SkriptParser.@NotNull ParseResult parseResult) {
return SkriptAdapter.getInstance().isCurrentEvents(ServerEvent.class);
}
}
|
3e0933dcc16c665c37c25b721f5e5bf45c01e98d | 2,084 | java | Java | solr/contrib/analytics/src/java/org/apache/solr/analytics/stream/reservation/ReductionDataReservation.java | tizianodeg/lucene-solr | 8c7b709c08662d396bd12b1e352db99bb489a7da | [
"Apache-2.0"
] | 585 | 2015-01-04T06:12:50.000Z | 2022-03-31T14:20:42.000Z | solr/contrib/analytics/src/java/org/apache/solr/analytics/stream/reservation/ReductionDataReservation.java | tizianodeg/lucene-solr | 8c7b709c08662d396bd12b1e352db99bb489a7da | [
"Apache-2.0"
] | 394 | 2021-03-10T13:55:50.000Z | 2022-03-31T23:29:56.000Z | solr/contrib/analytics/src/java/org/apache/solr/analytics/stream/reservation/ReductionDataReservation.java | tizianodeg/lucene-solr | 8c7b709c08662d396bd12b1e352db99bb489a7da | [
"Apache-2.0"
] | 378 | 2015-01-13T11:40:27.000Z | 2022-03-31T14:20:59.000Z | 39.320755 | 118 | 0.761996 | 3,891 | /*
* 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.solr.analytics.stream.reservation;
import java.io.DataInput;
import java.io.DataOutput;
import org.apache.solr.analytics.function.reduction.data.ReductionDataCollector;
import org.apache.solr.analytics.stream.reservation.read.ReductionDataReader;
import org.apache.solr.analytics.stream.reservation.write.ReductionDataWriter;
/**
* A reservation allows a {@link ReductionDataCollector} to specify a piece of data it needs to export from the shard.
*/
public abstract class ReductionDataReservation<A, E> {
protected final A applier;
protected final E extractor;
protected ReductionDataReservation(A applier, E extractor) {
this.applier = applier;
this.extractor = extractor;
}
/**
* Generate a {@link ReductionDataReader} that merges the set of data this reservation represents.
*
* @param input the shard input stream
* @return a reader from the given input
*/
public abstract ReductionDataReader<A> createReadStream(DataInput input);
/**
* Generate a {@link ReductionDataWriter} that exports the set of data this reservation represents.
*
* @param output the shard output stream
* @return a writer to the given output
*/
public abstract ReductionDataWriter<E> createWriteStream(DataOutput output);
} |
3e09340a1ac140fc04633b3a222d8e894f89089c | 5,250 | java | Java | WenjaPvP - KitMap/src/server/wenjapvp/hcf/faction/argument/FactionInviteArgument.java | disclearing/WenjaPVP-is-skid | ea930f104f7f6ab1f3dbc3d76ad5ccdf07cf6506 | [
"Apache-2.0"
] | 1 | 2019-03-02T22:08:41.000Z | 2019-03-02T22:08:41.000Z | WenjaPvP - HCFactions/src/server/wenjapvp/hcf/faction/argument/FactionInviteArgument.java | disclearing/WenjaPVP-is-skid | ea930f104f7f6ab1f3dbc3d76ad5ccdf07cf6506 | [
"Apache-2.0"
] | null | null | null | WenjaPvP - HCFactions/src/server/wenjapvp/hcf/faction/argument/FactionInviteArgument.java | disclearing/WenjaPVP-is-skid | ea930f104f7f6ab1f3dbc3d76ad5ccdf07cf6506 | [
"Apache-2.0"
] | 1 | 2020-11-26T07:04:26.000Z | 2020-11-26T07:04:26.000Z | 39.772727 | 196 | 0.633524 | 3,892 | package server.wenjapvp.hcf.faction.argument;
import com.doctordark.util.chat.ClickAction;
import com.doctordark.util.chat.Text;
import com.doctordark.util.command.CommandArgument;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import server.wenjapvp.hcf.faction.struct.Relation;
import server.wenjapvp.hcf.faction.struct.Role;
import server.wenjapvp.hcf.HCF;
import server.wenjapvp.hcf.faction.type.Faction;
import server.wenjapvp.hcf.faction.type.PlayerFaction;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
/**
* Faction argument used to invite players into {@link Faction}s.
*/
public class FactionInviteArgument extends CommandArgument {
private static final Pattern USERNAME_REGEX = Pattern.compile("^[a-zA-Z0-9_]{2,16}$");
private final HCF plugin;
public FactionInviteArgument(HCF plugin) {
super("invite", "Invite a player to the faction.");
this.plugin = plugin;
this.aliases = new String[] { "inv", "invitemember", "inviteplayer" };
}
@Override
public String getUsage(String label) {
return '/' + label + ' ' + getName() + " <playerName>";
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Only players can invite to a faction.");
return true;
}
if (args.length < 2) {
sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
return true;
}
if (!USERNAME_REGEX.matcher(args[1]).matches()) {
sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is an invalid username.");
return true;
}
Player player = (Player) sender;
PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
if (playerFaction == null) {
sender.sendMessage(ChatColor.RED + "You are not in a faction.");
return true;
}
if (playerFaction.getMember(player.getUniqueId()).getRole() == Role.MEMBER) {
sender.sendMessage(ChatColor.RED + "You must a faction officer to invite members.");
return true;
}
Set<String> invitedPlayerNames = playerFaction.getInvitedPlayerNames();
String name = args[1];
if (playerFaction.getMember(name) != null) {
sender.sendMessage(ChatColor.RED + "'" + name + "' is already in your faction.");
return true;
}
if (!plugin.getEotwHandler().isEndOfTheWorld() && playerFaction.isRaidable()) {
sender.sendMessage(ChatColor.RED + "You may not invite players whilst your faction is raidable.");
return true;
}
if (!invitedPlayerNames.add(name)) {
sender.sendMessage(ChatColor.RED + name + " has already been invited.");
return true;
}
Player target = Bukkit.getPlayer(name);
if (target != null) {
name = target.getName(); // fix casing.
Text text = new Text(sender.getName()).setColor(Relation.ENEMY.toChatColour()).append(new Text(" has invited you to join ").setColor(ChatColor.YELLOW));
text.append(new Text(playerFaction.getName()).setColor(Relation.ENEMY.toChatColour())).append(new Text(". ").setColor(ChatColor.YELLOW));
text.append(
new Text("Click here").setColor(ChatColor.GREEN).setClick(ClickAction.RUN_COMMAND, '/' + label + " accept " + playerFaction.getName())
.setHoverText(ChatColor.AQUA + "Click to join " + playerFaction.getDisplayName(target) + ChatColor.AQUA + '.')).append(
new Text(" to accept this invitation.").setColor(ChatColor.YELLOW));
text.send(target);
}
playerFaction
.broadcast(Relation.MEMBER.toChatColour() + sender.getName() + ChatColor.YELLOW + " has invited " + Relation.ENEMY.toChatColour() + name + ChatColor.YELLOW + " into the faction.");
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 2 || !(sender instanceof Player)) {
return Collections.emptyList();
}
Player player = (Player) sender;
PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
if (playerFaction == null || (playerFaction.getMember(player.getUniqueId()).getRole() == Role.MEMBER)) {
return Collections.emptyList();
}
List<String> results = new ArrayList<>();
for (Player target : Bukkit.getOnlinePlayers()) {
if (player.canSee(target) && !results.contains(target.getName())) {
if (playerFaction != plugin.getFactionManager().getPlayerFaction(target.getUniqueId())) {
results.add(target.getName());
}
}
}
return results;
}
}
|
3e09346385b3045d0e8cce53bd3d0a2c1d57c4bb | 6,455 | java | Java | src/ui/TimePanel.java | CSNE/SMAnimator | c83f9393f3827ef7bf5d27ed627dc10358aea4c8 | [
"MIT"
] | 2 | 2016-03-10T01:30:32.000Z | 2016-03-15T09:16:53.000Z | src/ui/TimePanel.java | CSNE/SMAnimator | c83f9393f3827ef7bf5d27ed627dc10358aea4c8 | [
"MIT"
] | null | null | null | src/ui/TimePanel.java | CSNE/SMAnimator | c83f9393f3827ef7bf5d27ed627dc10358aea4c8 | [
"MIT"
] | null | null | null | 28.946188 | 186 | 0.656081 | 3,893 | package ui;
import animation.Keyframe;
import interfaces.OnModeChangeListener;
import interfaces.OnObjectSelectedListener;
import interfaces.OnObjectUpdateListener;
import interfaces.OnTimeUpdateListener;
import managers.ModeManager;
import managers.TimeManager;
import helpers.GeometricPrimitives;
import shapes.TransformableShape;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.Rectangle2D;
/**
* Created by Chan on 2016-01-02.
*/
public class TimePanel extends JPanel implements OnTimeUpdateListener, MouseMotionListener, MouseListener, OnModeChangeListener, OnObjectSelectedListener, OnObjectUpdateListener{
double drawRegionX,drawRegionY;
TimeManager tm;
ModeManager mm;
Rectangle2D.Double button;
TransformableShape selected;
double keyframeSquareSize=5;
double keyframeYIni=7, keyframeYDelta=7;
public TimePanel(TimeManager tm, ModeManager mm){
this.tm=tm;
this.mm=mm;
setPreferredSize(new Dimension(500,50));
addMouseMotionListener(this);
addMouseListener(this);
}
public void paintComponent(Graphics g) {
drawRegionX = getSize().getWidth();
drawRegionY = getSize().getHeight();
//System.out.println(drawRegionX+" / "+drawRegionY);
//Anti-aliasing
Graphics2D g2d = (Graphics2D) g;
RenderingHints rh = new RenderingHints(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHints(rh);
super.paintComponent(g2d);
//Time Tick
g2d.setColor(Color.BLACK);
double per=getPixelsPerSecond();
for (int i = 0; i < tm.getAnimationLength(); i++) {
g2d.fill(new Rectangle2D.Double(drawRegionY+per*i,drawRegionY/2.0,1,drawRegionY/2.0));
}
//Keyframes
if (selected!=null) {
g2d.setColor(new Color(255, 235, 113));
for (Keyframe kf:selected.getKeyFramedX().getKeyframes()){
g2d.fill(new Rectangle2D.Double(timeToX(kf.getTime())-keyframeSquareSize/2.0,keyframeYIni-keyframeSquareSize/2.0,keyframeSquareSize,keyframeSquareSize));
}
g2d.setColor(new Color(232, 138, 104));
for (Keyframe kf:selected.getKeyFramedY().getKeyframes()){
g2d.fill(new Rectangle2D.Double(timeToX(kf.getTime())-keyframeSquareSize/2.0,keyframeYIni+keyframeYDelta-keyframeSquareSize/2.0,keyframeSquareSize,keyframeSquareSize));
}
g2d.setColor(new Color(219, 127, 255));
for (Keyframe kf:selected.getKeyFramedScaleX().getKeyframes()){
g2d.fill(new Rectangle2D.Double(timeToX(kf.getTime())-keyframeSquareSize/2.0,keyframeYIni+keyframeYDelta*2-keyframeSquareSize/2.0,keyframeSquareSize,keyframeSquareSize));
}
g2d.setColor(new Color(104, 179, 232));
for (Keyframe kf:selected.getKeyFramedScaleY().getKeyframes()){
g2d.fill(new Rectangle2D.Double(timeToX(kf.getTime())-keyframeSquareSize/2.0,keyframeYIni+keyframeYDelta*3-keyframeSquareSize/2.0,keyframeSquareSize,keyframeSquareSize));
}
g2d.setColor(new Color(114, 255, 123));
for (Keyframe kf:selected.getKeyFramedRotation().getKeyframes()){
g2d.fill(new Rectangle2D.Double(timeToX(kf.getTime())-keyframeSquareSize/2.0,keyframeYIni+keyframeYDelta*4-keyframeSquareSize/2.0,keyframeSquareSize,keyframeSquareSize));
}
}
//Current Time Indicator
g2d.setColor(Color.RED);
g2d.fill(new Rectangle2D.Double(timeToX(tm.getCurrentAnimationTime())-1,0,2,drawRegionY));
//Buttons
button=new Rectangle2D.Double(0,0,drawRegionY,drawRegionY);
g2d.setColor(Color.BLACK);
g2d.fill(button);
g2d.setColor(Color.WHITE);
if (!tm.isPlaying()) g2d.fill(new GeometricPrimitives(GeometricPrimitives.TRIANGLE).scale(0.3).rotate(90).translate(drawRegionY/2.0,drawRegionY/2.0).getPath2D());
else {
g2d.fill(new GeometricPrimitives(GeometricPrimitives.SQUARE).scale(0.1,0.3).translate(drawRegionY/2.0-10,drawRegionY/2.0).getPath2D());
g2d.fill(new GeometricPrimitives(GeometricPrimitives.SQUARE).scale(0.1,0.3).translate(drawRegionY/2.0+10,drawRegionY/2.0).getPath2D());
}
setBackground(Color.lightGray);
}
private double getTimeBarWidth(){
return drawRegionX-drawRegionY; //this may change in the future, hence the method.
}
private double timeToX(double time){
return time/tm.getAnimationLength()*getTimeBarWidth()+drawRegionY;
}
private double getPixelsPerSecond(){
return getTimeBarWidth()/tm.getAnimationLength();
}
private double coordinatesToTime(MouseEvent e){
return coordinatesToTime(e.getX(),e.getY());
}
private double coordinatesToTime(int x, int y){
if (x>drawRegionY){
return (x-drawRegionY)/getTimeBarWidth()*tm.getAnimationLength();
}
else return 0.0;
}
@Override
public void updateTime() {
repaint();
}
@Override
public void mouseClicked(MouseEvent e) {
if (button.contains(e.getX(),e.getY())){
tm.togglePlayState();
}else{
tm.setTime(coordinatesToTime(e));
}
repaint();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mouseDragged(MouseEvent e) {
if (button.contains(e.getX(),e.getY())){
//pass
}else{
tm.setTime(coordinatesToTime(e));
}
repaint();
}
@Override
public void mouseMoved(MouseEvent e) {
}
@Override
public void modeChanged(int newMode) {
if(mm.higherThanOET(ModeManager.INTERMEDIATE)){
setVisible(true);
}else{
setVisible(false);
}
}
@Override
public void onSelect(TransformableShape shape) {
this.selected=shape;
}
@Override
public void updateObject() {
repaint();
}
}
|
3e0934be27ad72e4d717e4d94ce4de8435d9dfb9 | 96 | java | Java | Variant Programs/1-2/3/breeder/FarmCentral.java | hjc851/Dataset2-HowToDetectAdvancedSourceCodePlagiarism | a42ced1d5a92963207e3565860cac0946312e1b3 | [
"MIT"
] | null | null | null | Variant Programs/1-2/3/breeder/FarmCentral.java | hjc851/Dataset2-HowToDetectAdvancedSourceCodePlagiarism | a42ced1d5a92963207e3565860cac0946312e1b3 | [
"MIT"
] | null | null | null | Variant Programs/1-2/3/breeder/FarmCentral.java | hjc851/Dataset2-HowToDetectAdvancedSourceCodePlagiarism | a42ced1d5a92963207e3565860cac0946312e1b3 | [
"MIT"
] | null | null | null | 10.666667 | 25 | 0.71875 | 3,894 | package breeder;
public enum FarmCentral {
malnourished,
clog,
functioning,
slumber;
}
|
3e0934eaeb20fbed9fa4d34b619e05568fd712c9 | 3,319 | java | Java | src/main/java/com/tencentcloudapi/domain/v20180808/models/RenewDomainBatchRequest.java | feixueck/tencentcloud-sdk-java | ebdfb9cf12ce7630f53b387e2ac8d17471c6c7d0 | [
"Apache-2.0"
] | null | null | null | src/main/java/com/tencentcloudapi/domain/v20180808/models/RenewDomainBatchRequest.java | feixueck/tencentcloud-sdk-java | ebdfb9cf12ce7630f53b387e2ac8d17471c6c7d0 | [
"Apache-2.0"
] | null | null | null | src/main/java/com/tencentcloudapi/domain/v20180808/models/RenewDomainBatchRequest.java | feixueck/tencentcloud-sdk-java | ebdfb9cf12ce7630f53b387e2ac8d17471c6c7d0 | [
"Apache-2.0"
] | null | null | null | 23.048611 | 83 | 0.63965 | 3,895 | /*
* Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* 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.tencentcloudapi.domain.v20180808.models;
import com.tencentcloudapi.common.AbstractModel;
import com.google.gson.annotations.SerializedName;
import com.google.gson.annotations.Expose;
import java.util.HashMap;
public class RenewDomainBatchRequest extends AbstractModel{
/**
* 域名续费的年限。
*/
@SerializedName("Period")
@Expose
private Long Period;
/**
* 批量续费的域名。
*/
@SerializedName("Domains")
@Expose
private String [] Domains;
/**
* 付费模式 0手动在线付费,1使用余额付费。
*/
@SerializedName("PayMode")
@Expose
private Long PayMode;
/**
* 自动续费开关。有三个可选值:
0 表示关闭,不自动续费
1 表示开启,将自动续费
2 表示不处理,保留域名原有状态(默认值)
*/
@SerializedName("AutoRenewFlag")
@Expose
private Long AutoRenewFlag;
/**
* Get 域名续费的年限。
* @return Period 域名续费的年限。
*/
public Long getPeriod() {
return this.Period;
}
/**
* Set 域名续费的年限。
* @param Period 域名续费的年限。
*/
public void setPeriod(Long Period) {
this.Period = Period;
}
/**
* Get 批量续费的域名。
* @return Domains 批量续费的域名。
*/
public String [] getDomains() {
return this.Domains;
}
/**
* Set 批量续费的域名。
* @param Domains 批量续费的域名。
*/
public void setDomains(String [] Domains) {
this.Domains = Domains;
}
/**
* Get 付费模式 0手动在线付费,1使用余额付费。
* @return PayMode 付费模式 0手动在线付费,1使用余额付费。
*/
public Long getPayMode() {
return this.PayMode;
}
/**
* Set 付费模式 0手动在线付费,1使用余额付费。
* @param PayMode 付费模式 0手动在线付费,1使用余额付费。
*/
public void setPayMode(Long PayMode) {
this.PayMode = PayMode;
}
/**
* Get 自动续费开关。有三个可选值:
0 表示关闭,不自动续费
1 表示开启,将自动续费
2 表示不处理,保留域名原有状态(默认值)
* @return AutoRenewFlag 自动续费开关。有三个可选值:
0 表示关闭,不自动续费
1 表示开启,将自动续费
2 表示不处理,保留域名原有状态(默认值)
*/
public Long getAutoRenewFlag() {
return this.AutoRenewFlag;
}
/**
* Set 自动续费开关。有三个可选值:
0 表示关闭,不自动续费
1 表示开启,将自动续费
2 表示不处理,保留域名原有状态(默认值)
* @param AutoRenewFlag 自动续费开关。有三个可选值:
0 表示关闭,不自动续费
1 表示开启,将自动续费
2 表示不处理,保留域名原有状态(默认值)
*/
public void setAutoRenewFlag(Long AutoRenewFlag) {
this.AutoRenewFlag = AutoRenewFlag;
}
/**
* Internal implementation, normal users should not use it.
*/
public void toMap(HashMap<String, String> map, String prefix) {
this.setParamSimple(map, prefix + "Period", this.Period);
this.setParamArraySimple(map, prefix + "Domains.", this.Domains);
this.setParamSimple(map, prefix + "PayMode", this.PayMode);
this.setParamSimple(map, prefix + "AutoRenewFlag", this.AutoRenewFlag);
}
}
|
3e0934f46b8dee9f543fa1268079e75acb719cac | 2,432 | java | Java | server-core/src/main/java/io/onedev/server/web/editable/CommitQueryEditSupport.java | simgagne/onedev | fd974b295c8c00fbc1be3729830a8d1277cf55e5 | [
"MIT"
] | 1 | 2020-12-07T02:47:58.000Z | 2020-12-07T02:47:58.000Z | server-core/src/main/java/io/onedev/server/web/editable/CommitQueryEditSupport.java | hslooooooool/onedev | 5621ed17eb8209442967bfb36f70a299bdbe9cfc | [
"MIT"
] | 2 | 2021-02-21T18:41:18.000Z | 2021-02-21T22:20:07.000Z | server-core/src/main/java/io/onedev/server/web/editable/CommitQueryEditSupport.java | hslooooooool/onedev | 5621ed17eb8209442967bfb36f70a299bdbe9cfc | [
"MIT"
] | 1 | 2021-04-15T17:46:20.000Z | 2021-04-15T17:46:20.000Z | 31.179487 | 91 | 0.666118 | 3,896 | package io.onedev.server.web.editable;
import java.lang.reflect.Method;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import io.onedev.server.model.Project;
import io.onedev.server.web.behavior.CommitQueryBehavior;
import io.onedev.server.web.behavior.inputassist.InputAssistBehavior;
import io.onedev.server.web.editable.annotation.CommitQuery;
import io.onedev.server.web.editable.string.StringPropertyEditor;
import io.onedev.server.web.page.project.ProjectPage;
@SuppressWarnings("serial")
public class CommitQueryEditSupport implements EditSupport {
@Override
public PropertyContext<?> getEditContext(PropertyDescriptor descriptor) {
Method propertyGetter = descriptor.getPropertyGetter();
if (propertyGetter.getAnnotation(CommitQuery.class) != null) {
if (propertyGetter.getReturnType() != String.class) {
throw new RuntimeException("Annotation 'CommitQuery' should be applied to property "
+ "with type 'String'");
}
return new PropertyContext<String>(descriptor) {
@Override
public PropertyViewer renderForView(String componentId, final IModel<String> model) {
return new PropertyViewer(componentId, descriptor) {
@Override
protected Component newContent(String id, PropertyDescriptor propertyDescriptor) {
String query = model.getObject();
if (query != null) {
return new Label(id, query);
} else {
return new EmptyValueLabel(id, propertyDescriptor.getPropertyGetter());
}
}
};
}
@Override
public PropertyEditor<String> renderForEdit(String componentId, IModel<String> model) {
return new StringPropertyEditor(componentId, descriptor, model) {
@Override
protected InputAssistBehavior getInputAssistBehavior() {
return new CommitQueryBehavior(new AbstractReadOnlyModel<Project>() {
@Override
public Project getObject() {
return ((ProjectPage) getPage()).getProject();
}
});
}
};
}
};
} else {
return null;
}
}
@Override
public int getPriority() {
return DEFAULT_PRIORITY;
}
}
|
3e0934fe8a5ea4d654da837b007fe8647e2029f1 | 3,730 | java | Java | Corpus/aspectj/6096.java | JamesCao2048/BlizzardData | a524bec4f0d297bb748234eeb1c2fcdee3dce7d7 | [
"MIT"
] | 1 | 2022-01-15T02:47:45.000Z | 2022-01-15T02:47:45.000Z | Corpus/aspectj/6096.java | JamesCao2048/BlizzardData | a524bec4f0d297bb748234eeb1c2fcdee3dce7d7 | [
"MIT"
] | null | null | null | Corpus/aspectj/6096.java | JamesCao2048/BlizzardData | a524bec4f0d297bb748234eeb1c2fcdee3dce7d7 | [
"MIT"
] | null | null | null | 27.028986 | 130 | 0.719303 | 3,897 | /* *******************************************************************
* Copyright (c) 2010 Contributors
* All rights reserved.
* 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
*
* Contributors:
* Andy Clement
* Nieraj Singh
* ******************************************************************/
package org.aspectj.weaver.patterns;
import java.io.IOException;
import java.util.Map;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.CompressingDataOutputStream;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.World;
/**
* A TypeCategoryTypePattern matches on the category of a type, one of class/interface/aspect/inner/anonymous/enum/annotation, and
* these are specified in the pointcut via isClass() isInterface() isAspect() isInner() isAnonymous() isEnum() isAnnotation().
*
* @author Andy Clement
* @since 1.6.9
*/
public class TypeCategoryTypePattern extends TypePattern {
public static final int CLASS = 1;
public static final int INTERFACE = 2;
public static final int ASPECT = 3;
public static final int INNER = 4;
public static final int ANONYMOUS = 5;
public static final int ENUM = 6;
public static final int ANNOTATION = 7;
private int category;
private int VERSION = 1;
public TypeCategoryTypePattern(int category) {
super(false);
this.category = category;
}
public int getTypeCategory() {
return category;
}
@Override
protected boolean matchesExactly(ResolvedType type) {
return isRightCategory(type);
}
@Override
protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) {
return isRightCategory(type);
}
@Override
public FuzzyBoolean matchesInstanceof(ResolvedType type) {
return FuzzyBoolean.fromBoolean(isRightCategory(type));
}
@Override
public TypePattern parameterizeWith(Map typeVariableMap, World w) {
return this;
}
@Override
public Object accept(PatternNodeVisitor visitor, Object data) {
return visitor.visit(this, data);
}
@Override
public boolean equals(Object other) {
if (!(other instanceof TypeCategoryTypePattern)) {
return false;
}
TypeCategoryTypePattern o = (TypeCategoryTypePattern) other;
return o.category == category;
}
// TODO is sourcelocation part of the identity or just a 'nice to have' - if important it should be in hashcode/equals
// TODO but if that is the case it needs addressing for all type patterns
@Override
public int hashCode() {
return category * 37;
}
@Override
public void write(CompressingDataOutputStream s) throws IOException {
s.writeByte(TypePattern.TYPE_CATEGORY);
s.writeInt(VERSION);
s.writeInt(category);
writeLocation(s);
}
public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException {
int version = s.readInt();
int category = s.readInt();
TypeCategoryTypePattern tp = new TypeCategoryTypePattern(category);
tp.readLocation(context, s);
return tp;
}
/**
* @return true if the supplied type is of the category specified for this type pattern
*/
private boolean isRightCategory(ResolvedType type) {
switch (category) {
case CLASS:
return type.isClass();
case INTERFACE:
return type.isInterface();
case ASPECT:
return type.isAspect();
case ANONYMOUS:
return type.isAnonymous();
case INNER:
return type.isNested();
case ENUM:
return type.isEnum();
case ANNOTATION:
return type.isAnnotation();
}
return false;
}
}
|
3e09355e92a65fd361562bf71719d3315213e14b | 27,769 | java | Java | src/java/beans/PropertyDescriptor.java | AndyChenIT/jdk-1.7-annotated | 2a6b843c8f6ef5bb35c4180af1b51774a2c70cac | [
"Apache-2.0"
] | 63 | 2016-03-29T02:09:12.000Z | 2021-11-17T00:27:47.000Z | src/java/beans/PropertyDescriptor.java | AndyChenIT/jdk-1.7-annotated | 2a6b843c8f6ef5bb35c4180af1b51774a2c70cac | [
"Apache-2.0"
] | null | null | null | src/java/beans/PropertyDescriptor.java | AndyChenIT/jdk-1.7-annotated | 2a6b843c8f6ef5bb35c4180af1b51774a2c70cac | [
"Apache-2.0"
] | 77 | 2015-12-30T07:46:01.000Z | 2022-03-03T01:57:55.000Z | 36.346859 | 112 | 0.577803 | 3,898 | /*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package java.beans;
import java.lang.ref.Reference;
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;
/**
* A PropertyDescriptor describes one property that a Java Bean
* exports via a pair of accessor methods.
*/
public class PropertyDescriptor extends FeatureDescriptor {
private Reference<Class> propertyTypeRef;
private Reference<Method> readMethodRef;
private Reference<Method> writeMethodRef;
private Reference<Class> propertyEditorClassRef;
private boolean bound;
private boolean constrained;
// The base name of the method name which will be prefixed with the
// read and write method. If name == "foo" then the baseName is "Foo"
private String baseName;
private String writeMethodName;
private String readMethodName;
/**
* Constructs a PropertyDescriptor for a property that follows
* the standard Java convention by having getFoo and setFoo
* accessor methods. Thus if the argument name is "fred", it will
* assume that the writer method is "setFred" and the reader method
* is "getFred" (or "isFred" for a boolean property). Note that the
* property name should start with a lower case character, which will
* be capitalized in the method names.
*
* @param propertyName The programmatic name of the property.
* @param beanClass The Class object for the target bean. For
* example sun.beans.OurButton.class.
* @exception IntrospectionException if an exception occurs during
* introspection.
*/
public PropertyDescriptor(String propertyName, Class<?> beanClass)
throws IntrospectionException {
this(propertyName, beanClass,
Introspector.IS_PREFIX + NameGenerator.capitalize(propertyName),
Introspector.SET_PREFIX + NameGenerator.capitalize(propertyName));
}
/**
* This constructor takes the name of a simple property, and method
* names for reading and writing the property.
*
* @param propertyName The programmatic name of the property.
* @param beanClass The Class object for the target bean. For
* example sun.beans.OurButton.class.
* @param readMethodName The name of the method used for reading the property
* value. May be null if the property is write-only.
* @param writeMethodName The name of the method used for writing the property
* value. May be null if the property is read-only.
* @exception IntrospectionException if an exception occurs during
* introspection.
*/
public PropertyDescriptor(String propertyName, Class<?> beanClass,
String readMethodName, String writeMethodName)
throws IntrospectionException {
if (beanClass == null) {
throw new IntrospectionException("Target Bean class is null");
}
if (propertyName == null || propertyName.length() == 0) {
throw new IntrospectionException("bad property name");
}
if ("".equals(readMethodName) || "".equals(writeMethodName)) {
throw new IntrospectionException("read or write method name should not be the empty string");
}
setName(propertyName);
setClass0(beanClass);
this.readMethodName = readMethodName;
if (readMethodName != null && getReadMethod() == null) {
throw new IntrospectionException("Method not found: " + readMethodName);
}
this.writeMethodName = writeMethodName;
if (writeMethodName != null && getWriteMethod() == null) {
throw new IntrospectionException("Method not found: " + writeMethodName);
}
// If this class or one of its base classes allow PropertyChangeListener,
// then we assume that any properties we discover are "bound".
// See Introspector.getTargetPropertyInfo() method.
Class[] args = { PropertyChangeListener.class };
this.bound = null != Introspector.findMethod(beanClass, "addPropertyChangeListener", args.length, args);
}
/**
* This constructor takes the name of a simple property, and Method
* objects for reading and writing the property.
*
* @param propertyName The programmatic name of the property.
* @param readMethod The method used for reading the property value.
* May be null if the property is write-only.
* @param writeMethod The method used for writing the property value.
* May be null if the property is read-only.
* @exception IntrospectionException if an exception occurs during
* introspection.
*/
public PropertyDescriptor(String propertyName, Method readMethod, Method writeMethod)
throws IntrospectionException {
if (propertyName == null || propertyName.length() == 0) {
throw new IntrospectionException("bad property name");
}
setName(propertyName);
setReadMethod(readMethod);
setWriteMethod(writeMethod);
}
/**
* Creates <code>PropertyDescriptor</code> for the specified bean
* with the specified name and methods to read/write the property value.
*
* @param bean the type of the target bean
* @param base the base name of the property (the rest of the method name)
* @param read the method used for reading the property value
* @param write the method used for writing the property value
* @exception IntrospectionException if an exception occurs during introspection
*
* @since 1.7
*/
PropertyDescriptor(Class<?> bean, String base, Method read, Method write) throws IntrospectionException {
if (bean == null) {
throw new IntrospectionException("Target Bean class is null");
}
setClass0(bean);
setName(Introspector.decapitalize(base));
setReadMethod(read);
setWriteMethod(write);
this.baseName = base;
}
/**
* Returns the Java type info for the property.
* Note that the {@code Class} object may describe
* primitive Java types such as {@code int}.
* This type is returned by the read method
* or is used as the parameter type of the write method.
* Returns {@code null} if the type is an indexed property
* that does not support non-indexed access.
*
* @return the {@code Class} object that represents the Java type info,
* or {@code null} if the type cannot be determined
*/
public synchronized Class<?> getPropertyType() {
Class type = getPropertyType0();
if (type == null) {
try {
type = findPropertyType(getReadMethod(), getWriteMethod());
setPropertyType(type);
} catch (IntrospectionException ex) {
// Fall
}
}
return type;
}
private void setPropertyType(Class type) {
this.propertyTypeRef = getWeakReference(type);
}
private Class getPropertyType0() {
return (this.propertyTypeRef != null)
? this.propertyTypeRef.get()
: null;
}
/**
* Gets the method that should be used to read the property value.
*
* @return The method that should be used to read the property value.
* May return null if the property can't be read.
*/
public synchronized Method getReadMethod() {
Method readMethod = getReadMethod0();
if (readMethod == null) {
Class cls = getClass0();
if (cls == null || (readMethodName == null && readMethodRef == null)) {
// The read method was explicitly set to null.
return null;
}
String nextMethodName = Introspector.GET_PREFIX + getBaseName();
if (readMethodName == null) {
Class type = getPropertyType0();
if (type == boolean.class || type == null) {
readMethodName = Introspector.IS_PREFIX + getBaseName();
} else {
readMethodName = nextMethodName;
}
}
// Since there can be multiple write methods but only one getter
// method, find the getter method first so that you know what the
// property type is. For booleans, there can be "is" and "get"
// methods. If an "is" method exists, this is the official
// reader method so look for this one first.
readMethod = Introspector.findMethod(cls, readMethodName, 0);
if ((readMethod == null) && !readMethodName.equals(nextMethodName)) {
readMethodName = nextMethodName;
readMethod = Introspector.findMethod(cls, readMethodName, 0);
}
try {
setReadMethod(readMethod);
} catch (IntrospectionException ex) {
// fall
}
}
return readMethod;
}
/**
* Sets the method that should be used to read the property value.
*
* @param readMethod The new read method.
*/
public synchronized void setReadMethod(Method readMethod)
throws IntrospectionException {
if (readMethod == null) {
readMethodName = null;
readMethodRef = null;
return;
}
// The property type is determined by the read method.
setPropertyType(findPropertyType(readMethod, getWriteMethod0()));
setClass0(readMethod.getDeclaringClass());
readMethodName = readMethod.getName();
this.readMethodRef = getSoftReference(readMethod);
setTransient(readMethod.getAnnotation(Transient.class));
}
/**
* Gets the method that should be used to write the property value.
*
* @return The method that should be used to write the property value.
* May return null if the property can't be written.
*/
public synchronized Method getWriteMethod() {
Method writeMethod = getWriteMethod0();
if (writeMethod == null) {
Class cls = getClass0();
if (cls == null || (writeMethodName == null && writeMethodRef == null)) {
// The write method was explicitly set to null.
return null;
}
// We need the type to fetch the correct method.
Class type = getPropertyType0();
if (type == null) {
try {
// Can't use getPropertyType since it will lead to recursive loop.
type = findPropertyType(getReadMethod(), null);
setPropertyType(type);
} catch (IntrospectionException ex) {
// Without the correct property type we can't be guaranteed
// to find the correct method.
return null;
}
}
if (writeMethodName == null) {
writeMethodName = Introspector.SET_PREFIX + getBaseName();
}
Class[] args = (type == null) ? null : new Class[] { type };
writeMethod = Introspector.findMethod(cls, writeMethodName, 1, args);
if (writeMethod != null) {
if (!writeMethod.getReturnType().equals(void.class)) {
writeMethod = null;
}
}
try {
setWriteMethod(writeMethod);
} catch (IntrospectionException ex) {
// fall through
}
}
return writeMethod;
}
/**
* Sets the method that should be used to write the property value.
*
* @param writeMethod The new write method.
*/
public synchronized void setWriteMethod(Method writeMethod)
throws IntrospectionException {
if (writeMethod == null) {
writeMethodName = null;
writeMethodRef = null;
return;
}
// Set the property type - which validates the method
setPropertyType(findPropertyType(getReadMethod(), writeMethod));
setClass0(writeMethod.getDeclaringClass());
writeMethodName = writeMethod.getName();
this.writeMethodRef = getSoftReference(writeMethod);
setTransient(writeMethod.getAnnotation(Transient.class));
}
private Method getReadMethod0() {
return (this.readMethodRef != null)
? this.readMethodRef.get()
: null;
}
private Method getWriteMethod0() {
return (this.writeMethodRef != null)
? this.writeMethodRef.get()
: null;
}
/**
* Overridden to ensure that a super class doesn't take precedent
*/
void setClass0(Class clz) {
if (getClass0() != null && clz.isAssignableFrom(getClass0())) {
// dont replace a subclass with a superclass
return;
}
super.setClass0(clz);
}
/**
* Updates to "bound" properties will cause a "PropertyChange" event to
* get fired when the property is changed.
*
* @return True if this is a bound property.
*/
public boolean isBound() {
return bound;
}
/**
* Updates to "bound" properties will cause a "PropertyChange" event to
* get fired when the property is changed.
*
* @param bound True if this is a bound property.
*/
public void setBound(boolean bound) {
this.bound = bound;
}
/**
* Attempted updates to "Constrained" properties will cause a "VetoableChange"
* event to get fired when the property is changed.
*
* @return True if this is a constrained property.
*/
public boolean isConstrained() {
return constrained;
}
/**
* Attempted updates to "Constrained" properties will cause a "VetoableChange"
* event to get fired when the property is changed.
*
* @param constrained True if this is a constrained property.
*/
public void setConstrained(boolean constrained) {
this.constrained = constrained;
}
/**
* Normally PropertyEditors will be found using the PropertyEditorManager.
* However if for some reason you want to associate a particular
* PropertyEditor with a given property, then you can do it with
* this method.
*
* @param propertyEditorClass The Class for the desired PropertyEditor.
*/
public void setPropertyEditorClass(Class<?> propertyEditorClass) {
this.propertyEditorClassRef = getWeakReference((Class)propertyEditorClass);
}
/**
* Gets any explicit PropertyEditor Class that has been registered
* for this property.
*
* @return Any explicit PropertyEditor Class that has been registered
* for this property. Normally this will return "null",
* indicating that no special editor has been registered,
* so the PropertyEditorManager should be used to locate
* a suitable PropertyEditor.
*/
public Class<?> getPropertyEditorClass() {
return (this.propertyEditorClassRef != null)
? this.propertyEditorClassRef.get()
: null;
}
/**
* Constructs an instance of a property editor using the current
* property editor class.
* <p>
* If the property editor class has a public constructor that takes an
* Object argument then it will be invoked using the bean parameter
* as the argument. Otherwise, the default constructor will be invoked.
*
* @param bean the source object
* @return a property editor instance or null if a property editor has
* not been defined or cannot be created
* @since 1.5
*/
public PropertyEditor createPropertyEditor(Object bean) {
Object editor = null;
Class cls = getPropertyEditorClass();
if (cls != null) {
Constructor ctor = null;
if (bean != null) {
try {
ctor = cls.getConstructor(new Class[] { Object.class });
} catch (Exception ex) {
// Fall through
}
}
try {
if (ctor == null) {
editor = cls.newInstance();
} else {
editor = ctor.newInstance(new Object[] { bean });
}
} catch (Exception ex) {
// A serious error has occured.
// Proably due to an invalid property editor.
throw new RuntimeException("PropertyEditor not instantiated",
ex);
}
}
return (PropertyEditor)editor;
}
/**
* Compares this <code>PropertyDescriptor</code> against the specified object.
* Returns true if the objects are the same. Two <code>PropertyDescriptor</code>s
* are the same if the read, write, property types, property editor and
* flags are equivalent.
*
* @since 1.4
*/
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj != null && obj instanceof PropertyDescriptor) {
PropertyDescriptor other = (PropertyDescriptor)obj;
Method otherReadMethod = other.getReadMethod();
Method otherWriteMethod = other.getWriteMethod();
if (!compareMethods(getReadMethod(), otherReadMethod)) {
return false;
}
if (!compareMethods(getWriteMethod(), otherWriteMethod)) {
return false;
}
if (getPropertyType() == other.getPropertyType() &&
getPropertyEditorClass() == other.getPropertyEditorClass() &&
bound == other.isBound() && constrained == other.isConstrained() &&
writeMethodName == other.writeMethodName &&
readMethodName == other.readMethodName) {
return true;
}
}
return false;
}
/**
* Package private helper method for Descriptor .equals methods.
*
* @param a first method to compare
* @param b second method to compare
* @return boolean to indicate that the methods are equivalent
*/
boolean compareMethods(Method a, Method b) {
// Note: perhaps this should be a protected method in FeatureDescriptor
if ((a == null) != (b == null)) {
return false;
}
if (a != null && b != null) {
if (!a.equals(b)) {
return false;
}
}
return true;
}
/**
* Package-private constructor.
* Merge two property descriptors. Where they conflict, give the
* second argument (y) priority over the first argument (x).
*
* @param x The first (lower priority) PropertyDescriptor
* @param y The second (higher priority) PropertyDescriptor
*/
PropertyDescriptor(PropertyDescriptor x, PropertyDescriptor y) {
super(x,y);
if (y.baseName != null) {
baseName = y.baseName;
} else {
baseName = x.baseName;
}
if (y.readMethodName != null) {
readMethodName = y.readMethodName;
} else {
readMethodName = x.readMethodName;
}
if (y.writeMethodName != null) {
writeMethodName = y.writeMethodName;
} else {
writeMethodName = x.writeMethodName;
}
if (y.propertyTypeRef != null) {
propertyTypeRef = y.propertyTypeRef;
} else {
propertyTypeRef = x.propertyTypeRef;
}
// Figure out the merged read method.
Method xr = x.getReadMethod();
Method yr = y.getReadMethod();
// Normally give priority to y's readMethod.
try {
if (isAssignable(xr, yr)) {
setReadMethod(yr);
} else {
setReadMethod(xr);
}
} catch (IntrospectionException ex) {
// fall through
}
// However, if both x and y reference read methods in the same class,
// give priority to a boolean "is" method over a boolean "get" method.
if (xr != null && yr != null &&
xr.getDeclaringClass() == yr.getDeclaringClass() &&
getReturnType(getClass0(), xr) == boolean.class &&
getReturnType(getClass0(), yr) == boolean.class &&
xr.getName().indexOf(Introspector.IS_PREFIX) == 0 &&
yr.getName().indexOf(Introspector.GET_PREFIX) == 0) {
try {
setReadMethod(xr);
} catch (IntrospectionException ex) {
// fall through
}
}
Method xw = x.getWriteMethod();
Method yw = y.getWriteMethod();
try {
if (yw != null) {
setWriteMethod(yw);
} else {
setWriteMethod(xw);
}
} catch (IntrospectionException ex) {
// Fall through
}
if (y.getPropertyEditorClass() != null) {
setPropertyEditorClass(y.getPropertyEditorClass());
} else {
setPropertyEditorClass(x.getPropertyEditorClass());
}
bound = x.bound | y.bound;
constrained = x.constrained | y.constrained;
}
/*
* Package-private dup constructor.
* This must isolate the new object from any changes to the old object.
*/
PropertyDescriptor(PropertyDescriptor old) {
super(old);
propertyTypeRef = old.propertyTypeRef;
readMethodRef = old.readMethodRef;
writeMethodRef = old.writeMethodRef;
propertyEditorClassRef = old.propertyEditorClassRef;
writeMethodName = old.writeMethodName;
readMethodName = old.readMethodName;
baseName = old.baseName;
bound = old.bound;
constrained = old.constrained;
}
void updateGenericsFor(Class<?> type) {
setClass0(type);
try {
setPropertyType(findPropertyType(getReadMethod0(), getWriteMethod0()));
}
catch (IntrospectionException exception) {
setPropertyType(null);
}
}
/**
* Returns the property type that corresponds to the read and write method.
* The type precedence is given to the readMethod.
*
* @return the type of the property descriptor or null if both
* read and write methods are null.
* @throws IntrospectionException if the read or write method is invalid
*/
private Class findPropertyType(Method readMethod, Method writeMethod)
throws IntrospectionException {
Class propertyType = null;
try {
if (readMethod != null) {
Class[] params = getParameterTypes(getClass0(), readMethod);
if (params.length != 0) {
throw new IntrospectionException("bad read method arg count: "
+ readMethod);
}
propertyType = getReturnType(getClass0(), readMethod);
if (propertyType == Void.TYPE) {
throw new IntrospectionException("read method " +
readMethod.getName() + " returns void");
}
}
if (writeMethod != null) {
Class params[] = getParameterTypes(getClass0(), writeMethod);
if (params.length != 1) {
throw new IntrospectionException("bad write method arg count: "
+ writeMethod);
}
if (propertyType != null && !params[0].isAssignableFrom(propertyType)) {
throw new IntrospectionException("type mismatch between read and write methods");
}
propertyType = params[0];
}
} catch (IntrospectionException ex) {
throw ex;
}
return propertyType;
}
/**
* Returns a hash code value for the object.
* See {@link java.lang.Object#hashCode} for a complete description.
*
* @return a hash code value for this object.
* @since 1.5
*/
public int hashCode() {
int result = 7;
result = 37 * result + ((getPropertyType() == null) ? 0 :
getPropertyType().hashCode());
result = 37 * result + ((getReadMethod() == null) ? 0 :
getReadMethod().hashCode());
result = 37 * result + ((getWriteMethod() == null) ? 0 :
getWriteMethod().hashCode());
result = 37 * result + ((getPropertyEditorClass() == null) ? 0 :
getPropertyEditorClass().hashCode());
result = 37 * result + ((writeMethodName == null) ? 0 :
writeMethodName.hashCode());
result = 37 * result + ((readMethodName == null) ? 0 :
readMethodName.hashCode());
result = 37 * result + getName().hashCode();
result = 37 * result + ((bound == false) ? 0 : 1);
result = 37 * result + ((constrained == false) ? 0 : 1);
return result;
}
// Calculate once since capitalize() is expensive.
String getBaseName() {
if (baseName == null) {
baseName = NameGenerator.capitalize(getName());
}
return baseName;
}
void appendTo(StringBuilder sb) {
appendTo(sb, "bound", this.bound);
appendTo(sb, "constrained", this.constrained);
appendTo(sb, "propertyEditorClass", this.propertyEditorClassRef);
appendTo(sb, "propertyType", this.propertyTypeRef);
appendTo(sb, "readMethod", this.readMethodRef);
appendTo(sb, "writeMethod", this.writeMethodRef);
}
private boolean isAssignable(Method m1, Method m2) {
if (m1 == null) {
return true; // choose second method
}
if (m2 == null) {
return false; // choose first method
}
if (!m1.getName().equals(m2.getName())) {
return true; // choose second method by default
}
Class<?> type1 = m1.getDeclaringClass();
Class<?> type2 = m2.getDeclaringClass();
if (!type1.isAssignableFrom(type2)) {
return false; // choose first method: it declared later
}
type1 = getReturnType(getClass0(), m1);
type2 = getReturnType(getClass0(), m2);
if (!type1.isAssignableFrom(type2)) {
return false; // choose first method: it overrides return type
}
Class<?>[] args1 = getParameterTypes(getClass0(), m1);
Class<?>[] args2 = getParameterTypes(getClass0(), m2);
if (args1.length != args2.length) {
return true; // choose second method by default
}
for (int i = 0; i < args1.length; i++) {
if (!args1[i].isAssignableFrom(args2[i])) {
return false; // choose first method: it overrides parameter
}
}
return true; // choose second method
}
}
|
3e0935b861a547e8349688407a024ad5bb17ad29 | 5,426 | java | Java | build/tmp/expandedArchives/forge-1.18.1-39.0.40_mapped_parchment_2021.12.19-1.18.1-sources.jar_8da1e53bade44c6d138d26d6ab1ad1d3/net/minecraft/world/level/biome/Biomes.java | LX-s-Team/CookingLevel-Forge | 065ddf23d2efb4f44e0e494fb3b2cbef47b7cca5 | [
"MIT"
] | null | null | null | build/tmp/expandedArchives/forge-1.18.1-39.0.40_mapped_parchment_2021.12.19-1.18.1-sources.jar_8da1e53bade44c6d138d26d6ab1ad1d3/net/minecraft/world/level/biome/Biomes.java | LX-s-Team/CookingLevel-Forge | 065ddf23d2efb4f44e0e494fb3b2cbef47b7cca5 | [
"MIT"
] | null | null | null | build/tmp/expandedArchives/forge-1.18.1-39.0.40_mapped_parchment_2021.12.19-1.18.1-sources.jar_8da1e53bade44c6d138d26d6ab1ad1d3/net/minecraft/world/level/biome/Biomes.java | LX-s-Team/CookingLevel-Forge | 065ddf23d2efb4f44e0e494fb3b2cbef47b7cca5 | [
"MIT"
] | null | null | null | 74.328767 | 106 | 0.784372 | 3,899 | package net.minecraft.world.level.biome;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
public abstract class Biomes {
public static final ResourceKey<Biome> THE_VOID = register("the_void");
public static final ResourceKey<Biome> PLAINS = register("plains");
public static final ResourceKey<Biome> SUNFLOWER_PLAINS = register("sunflower_plains");
public static final ResourceKey<Biome> SNOWY_PLAINS = register("snowy_plains");
public static final ResourceKey<Biome> ICE_SPIKES = register("ice_spikes");
public static final ResourceKey<Biome> DESERT = register("desert");
public static final ResourceKey<Biome> SWAMP = register("swamp");
public static final ResourceKey<Biome> FOREST = register("forest");
public static final ResourceKey<Biome> FLOWER_FOREST = register("flower_forest");
public static final ResourceKey<Biome> BIRCH_FOREST = register("birch_forest");
public static final ResourceKey<Biome> DARK_FOREST = register("dark_forest");
public static final ResourceKey<Biome> OLD_GROWTH_BIRCH_FOREST = register("old_growth_birch_forest");
public static final ResourceKey<Biome> OLD_GROWTH_PINE_TAIGA = register("old_growth_pine_taiga");
public static final ResourceKey<Biome> OLD_GROWTH_SPRUCE_TAIGA = register("old_growth_spruce_taiga");
public static final ResourceKey<Biome> TAIGA = register("taiga");
public static final ResourceKey<Biome> SNOWY_TAIGA = register("snowy_taiga");
public static final ResourceKey<Biome> SAVANNA = register("savanna");
public static final ResourceKey<Biome> SAVANNA_PLATEAU = register("savanna_plateau");
public static final ResourceKey<Biome> WINDSWEPT_HILLS = register("windswept_hills");
public static final ResourceKey<Biome> WINDSWEPT_GRAVELLY_HILLS = register("windswept_gravelly_hills");
public static final ResourceKey<Biome> WINDSWEPT_FOREST = register("windswept_forest");
public static final ResourceKey<Biome> WINDSWEPT_SAVANNA = register("windswept_savanna");
public static final ResourceKey<Biome> JUNGLE = register("jungle");
public static final ResourceKey<Biome> SPARSE_JUNGLE = register("sparse_jungle");
public static final ResourceKey<Biome> BAMBOO_JUNGLE = register("bamboo_jungle");
public static final ResourceKey<Biome> BADLANDS = register("badlands");
public static final ResourceKey<Biome> ERODED_BADLANDS = register("eroded_badlands");
public static final ResourceKey<Biome> WOODED_BADLANDS = register("wooded_badlands");
public static final ResourceKey<Biome> MEADOW = register("meadow");
public static final ResourceKey<Biome> GROVE = register("grove");
public static final ResourceKey<Biome> SNOWY_SLOPES = register("snowy_slopes");
public static final ResourceKey<Biome> FROZEN_PEAKS = register("frozen_peaks");
public static final ResourceKey<Biome> JAGGED_PEAKS = register("jagged_peaks");
public static final ResourceKey<Biome> STONY_PEAKS = register("stony_peaks");
public static final ResourceKey<Biome> RIVER = register("river");
public static final ResourceKey<Biome> FROZEN_RIVER = register("frozen_river");
public static final ResourceKey<Biome> BEACH = register("beach");
public static final ResourceKey<Biome> SNOWY_BEACH = register("snowy_beach");
public static final ResourceKey<Biome> STONY_SHORE = register("stony_shore");
public static final ResourceKey<Biome> WARM_OCEAN = register("warm_ocean");
public static final ResourceKey<Biome> LUKEWARM_OCEAN = register("lukewarm_ocean");
public static final ResourceKey<Biome> DEEP_LUKEWARM_OCEAN = register("deep_lukewarm_ocean");
public static final ResourceKey<Biome> OCEAN = register("ocean");
public static final ResourceKey<Biome> DEEP_OCEAN = register("deep_ocean");
public static final ResourceKey<Biome> COLD_OCEAN = register("cold_ocean");
public static final ResourceKey<Biome> DEEP_COLD_OCEAN = register("deep_cold_ocean");
public static final ResourceKey<Biome> FROZEN_OCEAN = register("frozen_ocean");
public static final ResourceKey<Biome> DEEP_FROZEN_OCEAN = register("deep_frozen_ocean");
public static final ResourceKey<Biome> MUSHROOM_FIELDS = register("mushroom_fields");
public static final ResourceKey<Biome> DRIPSTONE_CAVES = register("dripstone_caves");
public static final ResourceKey<Biome> LUSH_CAVES = register("lush_caves");
public static final ResourceKey<Biome> NETHER_WASTES = register("nether_wastes");
public static final ResourceKey<Biome> WARPED_FOREST = register("warped_forest");
public static final ResourceKey<Biome> CRIMSON_FOREST = register("crimson_forest");
public static final ResourceKey<Biome> SOUL_SAND_VALLEY = register("soul_sand_valley");
public static final ResourceKey<Biome> BASALT_DELTAS = register("basalt_deltas");
public static final ResourceKey<Biome> THE_END = register("the_end");
public static final ResourceKey<Biome> END_HIGHLANDS = register("end_highlands");
public static final ResourceKey<Biome> END_MIDLANDS = register("end_midlands");
public static final ResourceKey<Biome> SMALL_END_ISLANDS = register("small_end_islands");
public static final ResourceKey<Biome> END_BARRENS = register("end_barrens");
private static ResourceKey<Biome> register(String pKey) {
return ResourceKey.create(Registry.BIOME_REGISTRY, new ResourceLocation(pKey));
}
} |
3e09372567c3e99e21488cc62786b7310e872663 | 1,989 | java | Java | src/min/datastructurenalgorithm/codility/FindLongest1Sequence.java | ddl2018/sandbox | bdf79ed2f1830a330cccacc3add03e239e09fd70 | [
"MIT"
] | null | null | null | src/min/datastructurenalgorithm/codility/FindLongest1Sequence.java | ddl2018/sandbox | bdf79ed2f1830a330cccacc3add03e239e09fd70 | [
"MIT"
] | null | null | null | src/min/datastructurenalgorithm/codility/FindLongest1Sequence.java | ddl2018/sandbox | bdf79ed2f1830a330cccacc3add03e239e09fd70 | [
"MIT"
] | null | null | null | 27.246575 | 63 | 0.424334 | 3,900 | package min.datastructurenalgorithm.codility;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FindLongest1Sequence {
public static void main(String args[]) {
FindLongest1Sequence tes = new FindLongest1Sequence();
tes.solution(111001);
}
public int solution(int X) {
int result = 0;
String origin = X + "";
String pattern = "1[1|0]*";
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(origin);
if (m.find()) {
//origin
result = find(origin);
} else {
StringBuilder input = new StringBuilder();
int i = 0;
while (X > 0) {
input.append(X % 2);
i++;
X = X / 2;
}
input = input.reverse();
result = find(input.toString());
}
return result;
}
public int find(String s) {
int count = 0;
String[] converted = s.split("");
List<String[]> ls = new ArrayList<String[]>();
String[] tmp = new String [s.length()];
for (int j = 0; j < converted.length; j++) {
tmp[j] = converted[j];
if (converted[j].equals("0")) {
tmp[j] = "1";
ls.add(tmp);
tmp = null;
}
}
int max = 0;
for (int j = 0; j < ls.size(); j++) {
for (int k = 0; k < ls.get(j).length; k++) {
if (ls.get(j)[k] == "1") {
max = max + 1;
} else {
if (count < max) {
count = max;
}
max = 0;
}
}
}
System.out.print(count);
return count;
}
}
|
3e0937b6017b8aabcc6a1c730696eacb8c6b1d6f | 2,834 | java | Java | sema4g-example/src/main/java/de/gishmo/gwt/sema4g/example/client/cases/Case05.java | mvp4g/sema4g | 540935a1ca3db7a8d3cd3960c03da06818c59636 | [
"Apache-2.0"
] | 2 | 2018-11-18T16:47:42.000Z | 2019-01-05T05:32:17.000Z | sema4g-example/src/main/java/de/gishmo/gwt/sema4g/example/client/cases/Case05.java | mvp4g/sema4g | 540935a1ca3db7a8d3cd3960c03da06818c59636 | [
"Apache-2.0"
] | 4 | 2017-11-26T17:41:02.000Z | 2018-06-21T14:47:42.000Z | sema4g-example/src/main/java/de/gishmo/gwt/sema4g/example/client/cases/Case05.java | mvp4g/sema4g | 540935a1ca3db7a8d3cd3960c03da06818c59636 | [
"Apache-2.0"
] | null | null | null | 36.805195 | 104 | 0.616796 | 3,901 | /*
* Copyright (c) 2017 - 2018 - Frank Hossfeld
*
* 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 de.gishmo.gwt.sema4g.example.client.cases;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.PopupPanel;
import com.github.mvp4g.sema4g.client.SeMa4g;
import com.github.mvp4g.sema4g.client.command.FinalCommand;
import com.github.mvp4g.sema4g.client.command.SeMa4gCommand;
import com.github.mvp4g.sema4g.client.exception.SeMa4gException;
import de.gishmo.gwt.sema4g.example.client.cases.code.Example;
@Example
public class Case05
extends AbstractCase {
public Case05(FlowPanel fp,
PopupPanel popup) {
super(fp,
popup);
descriptionText = "A single service call (service no. 13) which will fail and throw an exception." +
"<ul>" +
"<li>service 'one': the waiting duration on the server is: 2500 ms.</li>" +
"</ul>" +
"The context will end in error because of a server exception!" +
AbstractCase.SERVICE_FAILURE_DESCRIPTION +
AbstractCase.INITCOMMAND_DESCRIPTION +
AbstractCase.FINALCOMMAND_DESCRIPTION;
labelText = "Test Case 05";
startText = "Execution for test case five started";
successText = "Execution for case five finished";
errorText = "Execution for case five failed";
}
public void createContextAndRun() {
SeMa4gCommand command = this.createAsyncFailingCommandRPC(9250,
"thirteen");
try {
SeMa4g.builder()
.addInitCommand(super.createInitCommand())
.addFinalCommand(new FinalCommand() {
@Override
public void onSuccess() {
popup.hide();
Window.alert("Ups, seeing this means ... something is wrong!");
}
@Override
public void onFailure() {
popup.hide();
Window.alert("Fine, that's what we expected ... ");
}
})
.add(command)
.build()
.run();
} catch (SeMa4gException e) {
Window.alert("panic!!!!");
}
}
}
|
3e09380414265f469b6c67cef2e9d319cf288335 | 491 | java | Java | demo/kkalanhw2/src/main/java/com/example/kkalanhw2/dao/ProductCommentDao.java | Kaan010/study2-SpringOverview | 21fc4e892e1886fe37d24213d89c3dba3fb25a2b | [
"MIT"
] | null | null | null | demo/kkalanhw2/src/main/java/com/example/kkalanhw2/dao/ProductCommentDao.java | Kaan010/study2-SpringOverview | 21fc4e892e1886fe37d24213d89c3dba3fb25a2b | [
"MIT"
] | null | null | null | demo/kkalanhw2/src/main/java/com/example/kkalanhw2/dao/ProductCommentDao.java | Kaan010/study2-SpringOverview | 21fc4e892e1886fe37d24213d89c3dba3fb25a2b | [
"MIT"
] | null | null | null | 27.277778 | 79 | 0.830957 | 3,902 | package com.example.kkalanhw2.dao;
import com.example.kkalanhw2.entity.Product;
import com.example.kkalanhw2.entity.ProductComment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ProductCommentDao extends JpaRepository<ProductComment,Long> {
List<ProductComment> findAllByCustomerId(Long customerId);
List<ProductComment> findAllByProductId(Long productId);
}
|
3e09389ba0381124684b3af8e9eeefa9420b7782 | 249 | java | Java | src/code/generic/SortbyHeuristicCost.java | AbdelrahmanBadr3/Search-Agent | 6433b825e1439a415c510fe7578004a874b98f04 | [
"MIT"
] | null | null | null | src/code/generic/SortbyHeuristicCost.java | AbdelrahmanBadr3/Search-Agent | 6433b825e1439a415c510fe7578004a874b98f04 | [
"MIT"
] | null | null | null | src/code/generic/SortbyHeuristicCost.java | AbdelrahmanBadr3/Search-Agent | 6433b825e1439a415c510fe7578004a874b98f04 | [
"MIT"
] | null | null | null | 22.636364 | 67 | 0.767068 | 3,903 | package code.generic;
import java.util.Comparator;
public class SortbyHeuristicCost implements Comparator<SearchTree>
{
@Override
public int compare(SearchTree o1, SearchTree o2) {
return (int) (o1.heuristic_cost - o2.heuristic_cost);
}
} |
3e09395c6541d6d4bfb2a2b140c7c0f7312d27ac | 303 | java | Java | app/src/main/java/com/javalive09/demos/AlphaTest.java | javalive09/CodeBag | c7be3ac3e35284a49c76623769a3fa6dd10ee1a9 | [
"Apache-2.0"
] | 15 | 2015-05-15T02:58:29.000Z | 2021-03-05T02:09:23.000Z | app/src/main/java/com/javalive09/demos/AlphaTest.java | javalive09/CodeBag | c7be3ac3e35284a49c76623769a3fa6dd10ee1a9 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/javalive09/demos/AlphaTest.java | javalive09/CodeBag | c7be3ac3e35284a49c76623769a3fa6dd10ee1a9 | [
"Apache-2.0"
] | 4 | 2015-02-26T01:04:43.000Z | 2017-03-25T13:32:57.000Z | 17.823529 | 52 | 0.719472 | 3,904 | package com.javalive09.demos;
import com.javalive09.annotation.Run;
import com.javalive09.codebag.CodeActivity;
/**
* Created by peter on 2018/12/25
*/
public class AlphaTest {
@Run
public void show(CodeActivity codeActivity) {
codeActivity.setContentView(R.layout.alpha);
}
}
|
3e0939d6fb6cdac7b3e67536e12aa300dc1ac831 | 5,221 | java | Java | main/feature/src/boofcv/alg/feature/detect/intensity/impl/ImplSsdCorner_S16.java | jooink/BoofCV | 2b34e3b167f545e5bbc327bc7032adfdb7a1c3a0 | [
"Apache-2.0"
] | 1 | 2022-02-26T06:27:29.000Z | 2022-02-26T06:27:29.000Z | main/feature/src/boofcv/alg/feature/detect/intensity/impl/ImplSsdCorner_S16.java | jooink/BoofCV | 2b34e3b167f545e5bbc327bc7032adfdb7a1c3a0 | [
"Apache-2.0"
] | 2 | 2021-05-18T20:53:57.000Z | 2022-02-01T01:05:11.000Z | main/feature/src/boofcv/alg/feature/detect/intensity/impl/ImplSsdCorner_S16.java | jooink/BoofCV | 2b34e3b167f545e5bbc327bc7032adfdb7a1c3a0 | [
"Apache-2.0"
] | null | null | null | 27.051813 | 92 | 0.657345 | 3,905 | /*
* Copyright (c) 2011-2013, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
* 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 boofcv.alg.feature.detect.intensity.impl;
import boofcv.struct.image.ImageFloat32;
import boofcv.struct.image.ImageSInt16;
import boofcv.struct.image.ImageSInt32;
/**
* <p>
* Implementation of {@link ImplSsdCornerBase} for {@link ImageSInt16}.
* </p>
*
* <p>
* DO NOT MODIFY. Code has been automatically generated by {@link GenerateImplSsdCorner}.
* </p>
*
* @author Peter Abeles
*/
public abstract class ImplSsdCorner_S16 extends ImplSsdCornerBase<ImageSInt16,ImageSInt32> {
// temporary storage for convolution along in the vertical axis.
private int tempXX[] = new int[1];
private int tempXY[] = new int[1];
private int tempYY[] = new int[1];
// defines the A matrix, from which the eigenvalues are computed
protected int totalXX, totalYY, totalXY;
public ImplSsdCorner_S16( int windowRadius) {
super(windowRadius,ImageSInt32.class);
}
@Override
public void setImageShape( int imageWidth, int imageHeight ) {
super.setImageShape(imageWidth,imageHeight);
if( tempXX.length < imageWidth ) {
tempXX = new int[imageWidth];
tempXY = new int[imageWidth];
tempYY = new int[imageWidth];
}
}
/**
* Compute the derivative sum along the x-axis while taking advantage of duplicate
* calculations for each window.
*/
@Override
protected void horizontal() {
short[] dataX = derivX.data;
short[] dataY = derivY.data;
int[] hXX = horizXX.data;
int[] hXY = horizXY.data;
int[] hYY = horizYY.data;
final int imgHeight = derivX.getHeight();
final int imgWidth = derivX.getWidth();
int windowWidth = radius * 2 + 1;
int radp1 = radius + 1;
for (int row = 0; row < imgHeight; row++) {
int pix = row * imgWidth;
int end = pix + windowWidth;
int totalXX = 0;
int totalXY = 0;
int totalYY = 0;
int indexX = derivX.startIndex + row * derivX.stride;
int indexY = derivY.startIndex + row * derivY.stride;
for (; pix < end; pix++) {
short dx = dataX[indexX++];
short dy = dataY[indexY++];
totalXX += dx * dx;
totalXY += dx * dy;
totalYY += dy * dy;
}
hXX[pix - radp1] = totalXX;
hXY[pix - radp1] = totalXY;
hYY[pix - radp1] = totalYY;
end = row * imgWidth + imgWidth;
for (; pix < end; pix++, indexX++, indexY++) {
short dx = dataX[indexX - windowWidth];
short dy = dataY[indexY - windowWidth];
// saving these multiplications in an array to avoid recalculating them made
// the algorithm about 50% slower
totalXX -= dx * dx;
totalXY -= dx * dy;
totalYY -= dy * dy;
dx = dataX[indexX];
dy = dataY[indexY];
totalXX += dx * dx;
totalXY += dx * dy;
totalYY += dy * dy;
hXX[pix - radius] = totalXX;
hXY[pix - radius] = totalXY;
hYY[pix - radius] = totalYY;
}
}
}
/**
* Compute the derivative sum along the y-axis while taking advantage of duplicate
* calculations for each window and avoiding cache misses. Then compute the eigen values
*/
@Override
protected void vertical( ImageFloat32 intensity ) {
int[] hXX = horizXX.data;
int[] hXY = horizXY.data;
int[] hYY = horizYY.data;
final float[] inten = intensity.data;
final int imgHeight = horizXX.getHeight();
final int imgWidth = horizXX.getWidth();
final int kernelWidth = radius * 2 + 1;
final int startX = radius;
final int endX = imgWidth - radius;
final int backStep = kernelWidth * imgWidth;
for (x = startX; x < endX; x++) {
int srcIndex = x;
int destIndex = imgWidth * radius + x;
totalXX = totalXY = totalYY = 0;
int indexEnd = srcIndex + imgWidth * kernelWidth;
for (; srcIndex < indexEnd; srcIndex += imgWidth) {
totalXX += hXX[srcIndex];
totalXY += hXY[srcIndex];
totalYY += hYY[srcIndex];
}
tempXX[x] = totalXX;
tempXY[x] = totalXY;
tempYY[x] = totalYY;
y = radius;
// compute the eigen values
inten[destIndex] = computeIntensity();
destIndex += imgWidth;
y++;
}
// change the order it is processed in to reduce cache misses
for (y = radius + 1; y < imgHeight - radius; y++) {
int srcIndex = (y + radius) * imgWidth + startX;
int destIndex = y * imgWidth + startX;
for (x = startX; x < endX; x++, srcIndex++, destIndex++) {
totalXX = tempXX[x] - hXX[srcIndex - backStep];
tempXX[x] = totalXX += hXX[srcIndex];
totalXY = tempXY[x] - hXY[srcIndex - backStep];
tempXY[x] = totalXY += hXY[srcIndex];
totalYY = tempYY[x] - hYY[srcIndex - backStep];
tempYY[x] = totalYY += hYY[srcIndex];
inten[destIndex] = computeIntensity();
}
}
}
}
|
3e093acc7368b07868f968c1774469a1e46b7e85 | 4,239 | java | Java | xchange-binance/src/main/java/org/knowm/xchange/binance/futures/service/BinanceFuturesMarketDataService.java | nostro-im/XChange | 149555f7a015398d47c92fb28dffad220dd653f3 | [
"MIT"
] | null | null | null | xchange-binance/src/main/java/org/knowm/xchange/binance/futures/service/BinanceFuturesMarketDataService.java | nostro-im/XChange | 149555f7a015398d47c92fb28dffad220dd653f3 | [
"MIT"
] | 4 | 2021-11-19T11:48:59.000Z | 2022-01-31T12:03:04.000Z | xchange-binance/src/main/java/org/knowm/xchange/binance/futures/service/BinanceFuturesMarketDataService.java | nostro-im/XChange | 149555f7a015398d47c92fb28dffad220dd653f3 | [
"MIT"
] | null | null | null | 40.759615 | 143 | 0.761029 | 3,906 | package org.knowm.xchange.binance.futures.service;
import org.knowm.xchange.binance.BinanceAuthenticated;
import org.knowm.xchange.binance.BinanceExchange;
import org.knowm.xchange.binance.dto.marketdata.BinanceTicker24h;
import org.knowm.xchange.binance.futures.BinanceFuturesAdapter;
import org.knowm.xchange.binance.futures.BinanceFuturesAuthenticated;
import org.knowm.xchange.binance.futures.dto.meta.BinanceFuturesExchangeInfo;
import org.knowm.xchange.binance.service.BinanceMarketDataService;
import org.knowm.xchange.client.ResilienceRegistries;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.derivative.FuturesContract;
import org.knowm.xchange.dto.marketdata.OrderBook;
import org.knowm.xchange.dto.marketdata.Ticker;
import org.knowm.xchange.dto.marketdata.Trades;
import org.knowm.xchange.exceptions.NotAvailableFromExchangeException;
import org.knowm.xchange.instrument.Instrument;
import org.knowm.xchange.service.marketdata.params.Params;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
import static org.knowm.xchange.binance.BinanceResilience.REQUEST_WEIGHT_RATE_LIMITER;
public class BinanceFuturesMarketDataService extends BinanceMarketDataService {
public BinanceFuturesMarketDataService(BinanceExchange exchange, BinanceAuthenticated binance, ResilienceRegistries resilienceRegistries) {
super(exchange, binance, resilienceRegistries);
}
@Override
public Ticker getTicker(CurrencyPair currencyPair, Object... args) {
throw new NotAvailableFromExchangeException("getTicker");
}
@Override
public Ticker getTicker(Instrument instrument, Object... args) throws IOException {
if (instrument instanceof FuturesContract) {
FuturesContract futuresContract = (FuturesContract) instrument;
return BinanceFuturesAdapter.replaceInstrument(
super.getTicker(futuresContract.getCurrencyPair(), args), futuresContract);
}
throw new NotAvailableFromExchangeException("getTicker");
}
@Override
public List<Ticker> getTickers(Params params) throws IOException {
return super.getTickers(params).stream()
.map(
t ->
BinanceFuturesAdapter.replaceInstrument(
t, new FuturesContract(t.getCurrencyPair(), null)))
.collect(Collectors.toList());
}
@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) {
throw new NotAvailableFromExchangeException("getOrderBook");
}
@Override
public OrderBook getOrderBook(Instrument instrument, Object... args) throws IOException {
if (instrument instanceof FuturesContract) {
FuturesContract futuresContract = (FuturesContract) instrument;
return BinanceFuturesAdapter.replaceInstrument(
super.getOrderBook(futuresContract.getCurrencyPair(), args), futuresContract);
}
throw new NotAvailableFromExchangeException("getOrderBook");
}
@Override
public Trades getTrades(CurrencyPair currencyPair, Object... args) {
throw new NotAvailableFromExchangeException("getTrades");
}
@Override
public Trades getTrades(Instrument instrument, Object... args) throws IOException {
if (instrument instanceof FuturesContract) {
FuturesContract futuresContract = (FuturesContract) instrument;
return BinanceFuturesAdapter.replaceInstrument(
super.getTrades(futuresContract.getCurrencyPair(), args), futuresContract);
}
throw new NotAvailableFromExchangeException("getTrades");
}
public List<BinanceTicker24h> ticker24h() throws IOException {
return decorateApiCall(() -> binance.ticker24h())
.withRetry(retry("ticker24h"))
.withRateLimiter(rateLimiter(REQUEST_WEIGHT_RATE_LIMITER), 40)
.call();
}
protected int aggTradesPermits(Integer limit) {
return 20;
}
public BinanceFuturesExchangeInfo getFuturesExchangeInfo() throws IOException {
return decorateApiCall(((BinanceFuturesAuthenticated)binance)::futuresExchangeInfo)
.withRetry(retry("futuresExchangeInfo"))
.withRateLimiter(rateLimiter(REQUEST_WEIGHT_RATE_LIMITER))
.call();
}
}
|
3e093ae26ccba9ec878661561fd70970a4179402 | 4,248 | java | Java | oes-service/src/main/java/com/chachae/exam/service/impl/MajorServiceImpl.java | chachae/Online-Testing-Platform | 2fa912e3defa69b472b2e397bc6e49019c1e5b5d | [
"Apache-2.0"
] | 11 | 2020-09-07T05:19:33.000Z | 2022-03-08T12:54:23.000Z | oes-service/src/main/java/com/chachae/exam/service/impl/MajorServiceImpl.java | chachae/oes-stand-alone | 2fa912e3defa69b472b2e397bc6e49019c1e5b5d | [
"Apache-2.0"
] | 2 | 2020-03-30T11:49:15.000Z | 2020-04-04T10:39:22.000Z | oes-service/src/main/java/com/chachae/exam/service/impl/MajorServiceImpl.java | chachae/oes-stand-alone | 2fa912e3defa69b472b2e397bc6e49019c1e5b5d | [
"Apache-2.0"
] | 2 | 2021-01-17T07:12:31.000Z | 2022-02-08T14:18:47.000Z | 33.1875 | 98 | 0.727637 | 3,907 | package com.chachae.exam.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chachae.exam.common.dao.MajorDAO;
import com.chachae.exam.common.exception.ServiceException;
import com.chachae.exam.common.model.Major;
import com.chachae.exam.common.model.Paper;
import com.chachae.exam.common.util.FileUtil;
import com.chachae.exam.common.util.PageUtil;
import com.chachae.exam.service.AcademyService;
import com.chachae.exam.service.MajorService;
import com.chachae.exam.service.PaperService;
import com.chachae.exam.service.StudentService;
import java.io.File;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
/**
* 专业表服务实现类
*
* @author chachae
* @since 2020-02-08 14:26:53
*/
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class MajorServiceImpl extends ServiceImpl<MajorDAO, Major> implements MajorService {
private final MajorDAO majorDAO;
private final PaperService paperService;
private final AcademyService academyService;
private final StudentService studentService;
@Override
public Map<String, Object> listPage(Page<Major> page, Major major) {
return PageUtil.toPage(this.majorDAO.pageVo(page, major));
}
@Override
public List<Major> listByAcademyId(Integer academyId) {
LambdaQueryWrapper<Major> qw = new LambdaQueryWrapper<>();
qw.eq(Major::getAcademyId, academyId);
return this.majorDAO.selectList(qw);
}
@Override
public List<Major> listByMajorName(String majorName) {
LambdaQueryWrapper<Major> qw = new LambdaQueryWrapper<>();
qw.eq(Major::getMajor, majorName);
return this.majorDAO.selectList(qw);
}
@Async
@Override
@Transactional(rollbackFor = Exception.class)
public void importMajorsExcel(MultipartFile multipartFile) {
// 同步锁
synchronized (this) {
File file = FileUtil.toFile(multipartFile);
// 读取 Excel 中的数据
ExcelReader reader = ExcelUtil.getReader(file);
// 读取专业的信息
List<Major> majors = reader.read(3, 4, Major.class);
for (Major major : majors) {
// 归属学院代码以及专业名称不为空
if (major.getAcademyId() != null && major.getMajor() != null) {
// 检测学院代码是否存在,且专业名称是否重复
boolean isExist = this.academyService.getById(major.getAcademyId()) != null;
boolean isNotExist = this.academyService.selectByName(major.getMajor()) == null;
if (isExist && isNotExist) {
// 插入
baseMapper.insert(major);
}
} else {
throw new ServiceException("请检查表格数据是否有有误");
}
}
}
}
@Override
public boolean removeById(Serializable id) {
List<Paper> papers = this.paperService.selectByMajorId((int) id);
if (CollUtil.isNotEmpty(papers)) {
throw new ServiceException("专业存在试卷关联,请删除试卷后重试");
}
int studentCount = this.studentService.selectCountByMajorId((int) id);
if (studentCount > 0) {
throw new ServiceException("专业存在学生关联,请删除相关学生后重试");
}
baseMapper.deleteById(id);
return true;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean save(Major entity) {
if (CollUtil.isEmpty(this.listByMajorName(entity.getMajor()))) {
baseMapper.insert(entity);
return true;
} else {
throw new ServiceException("专业已存在,请重重新输入");
}
}
@Override
public boolean updateById(Major entity) {
if (CollUtil.isEmpty(this.listByMajorName(entity.getMajor()))) {
baseMapper.updateById(entity);
return true;
} else {
throw new ServiceException("专业已存在,请重重新输入");
}
}
}
|
3e093d2fbccc3e4924e9394ee06e9f2e7cc13bb5 | 11,053 | java | Java | lib_common/src/main/java/com/jenson/common/widget/RecyclerViewItemDecoration.java | CDJenson/Jetpack-mvvm | 0b7c9f633e62a36c1cac65deee789ffa8e149e9a | [
"Apache-2.0"
] | null | null | null | lib_common/src/main/java/com/jenson/common/widget/RecyclerViewItemDecoration.java | CDJenson/Jetpack-mvvm | 0b7c9f633e62a36c1cac65deee789ffa8e149e9a | [
"Apache-2.0"
] | null | null | null | lib_common/src/main/java/com/jenson/common/widget/RecyclerViewItemDecoration.java | CDJenson/Jetpack-mvvm | 0b7c9f633e62a36c1cac65deee789ffa8e149e9a | [
"Apache-2.0"
] | null | null | null | 36.239344 | 140 | 0.570433 | 3,908 | package com.jenson.common.widget;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
/**
* author: CDJenson
* date: 2020/6/19 17:00
* version: 1.0
* description: One-sentence description
*/
public class RecyclerViewItemDecoration extends RecyclerView.ItemDecoration {
public static final int HORIZONTAL_DIV = 0;
public static final int VERTICAL_DIV = 1;
public static final int GRID_DIV = 2;
private int mOrientation;
private int mDividerWidth = 0;
private Paint mPaint;
private boolean mFirstLineVisible = false;//是否绘制第一个item的分割线
private RecyclerViewItemDecoration(int orientation, int color, int dividerWidth, boolean firstLineVisible) {
mOrientation = orientation;
mDividerWidth = dividerWidth;
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setColor(color);
mPaint.setStyle(Paint.Style.FILL);
mFirstLineVisible = firstLineVisible;
}
@Override
public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
switch (mOrientation) {
case HORIZONTAL_DIV:
drawHorizontal(c, parent);
break;
case VERTICAL_DIV:
drawVertical(c, parent);
break;
case GRID_DIV:
drawGrid(c, parent);
break;
default:
drawVertical(c, parent);
break;
}
}
@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
int itemPosition = parent.getChildAdapterPosition(view);
RecyclerView.Adapter mAdapter = parent.getAdapter();
if (mAdapter != null) {
int mChildCount = mAdapter.getItemCount();
switch (mOrientation) {
case HORIZONTAL_DIV:
if (!mFirstLineVisible && itemPosition == 0) {
return;
}
outRect.set(mDividerWidth, 0, 0, 0);
break;
case VERTICAL_DIV:
if (!mFirstLineVisible && itemPosition == 0) {
return;
}
outRect.set(0, mDividerWidth, 0, 0);
break;
case GRID_DIV:
/**
* 表格格局分割线
* <p>
* 1:当是第一个Item的时候,四周全部需要分割线
* 2:当是第一行Item的时候,需要额外添加顶部的分割线
* 3:当是第一列Item的时候,需要额外添加左侧的分割线
* 4:默认情况全部添加底部和右侧的分割线
* </p>
*/
RecyclerView.LayoutManager mLayoutManager = parent.getLayoutManager();
if (mLayoutManager instanceof GridLayoutManager) {
GridLayoutManager mGridLayoutManager = (GridLayoutManager) mLayoutManager;
int mSpanCount = mGridLayoutManager.getSpanCount();
if (itemPosition == 0) {//1
outRect.set(mDividerWidth, mDividerWidth, mDividerWidth, mDividerWidth);
} else if ((itemPosition + 1) <= mSpanCount) {//2
outRect.set(0, mDividerWidth, mDividerWidth, mDividerWidth);
} else if (((itemPosition + mSpanCount) % mSpanCount) == 0) {//3
outRect.set(mDividerWidth, 0, mDividerWidth, mDividerWidth);
} else {//4
outRect.set(0, 0, mDividerWidth, mDividerWidth);
}
}
break;
default:
//纵向布局分割线
if (itemPosition != (mChildCount - 1)) {
outRect.set(0, 0, 0, mDividerWidth);
}
break;
}
}
}
/**
* 绘制横向列表分割线
*
* @param c 绘制容器
* @param parent RecyclerView
*/
private void drawHorizontal(Canvas c, RecyclerView parent) {
int mChildCount = parent.getChildCount();
for (int i = 0; i < mChildCount; i++) {
View mChild = parent.getChildAt(i);
drawLeft(c, mChild, parent);
}
}
/**
* 绘制纵向列表分割线
*
* @param c 绘制容器
* @param parent RecyclerView
*/
private void drawVertical(Canvas c, RecyclerView parent) {
int mChildCount = parent.getChildCount();
for (int i = 0; i < mChildCount; i++) {
View mChild = parent.getChildAt(i);
drawTop(c, mChild, parent);
}
}
/**
* 绘制表格类型分割线
*
* @param c 绘制容器
* @param parent RecyclerView
*/
private void drawGrid(Canvas c, RecyclerView parent) {
int mChildCount = parent.getChildCount();
for (int i = 0; i < mChildCount; i++) {
View mChild = parent.getChildAt(i);
RecyclerView.LayoutManager mLayoutManager = parent.getLayoutManager();
if (mLayoutManager instanceof GridLayoutManager) {
GridLayoutManager mGridLayoutManager = (GridLayoutManager) mLayoutManager;
int mSpanCount = mGridLayoutManager.getSpanCount();
if (i == 0) {
drawTop(c, mChild, parent);
drawLeft(c, mChild, parent);
}
if ((i + 1) <= mSpanCount) {
drawTop(c, mChild, parent);
}
if (((i + mSpanCount) % mSpanCount) == 0) {
drawLeft(c, mChild, parent);
}
drawRight(c, mChild, parent);
drawBottom(c, mChild, parent);
}
}
}
/**
* 绘制右边分割线
*
* @param c 绘制容器
* @param mChild 对应ItemView
* @param recyclerView RecyclerView
*/
private void drawLeft(Canvas c, View mChild, RecyclerView recyclerView) {
RecyclerView.LayoutParams mChildLayoutParams = (RecyclerView.LayoutParams) mChild.getLayoutParams();
int left = mChild.getLeft() - mDividerWidth - mChildLayoutParams.leftMargin;
int top = mChild.getTop() - mChildLayoutParams.topMargin;
int right = mChild.getLeft() - mChildLayoutParams.leftMargin;
int bottom;
if (isGridLayoutManager(recyclerView)) {
bottom = mChild.getBottom() + mChildLayoutParams.bottomMargin + mDividerWidth;
} else {
bottom = mChild.getBottom() + mChildLayoutParams.bottomMargin;
}
c.drawRect(left, top, right, bottom, mPaint);
}
/**
* 绘制顶部分割线
*
* @param c 绘制容器
* @param mChild 对应ItemView
* @param recyclerView RecyclerView
*/
private void drawTop(Canvas c, View mChild, RecyclerView recyclerView) {
RecyclerView.LayoutParams mChildLayoutParams = (RecyclerView.LayoutParams) mChild.getLayoutParams();
int left;
int top = mChild.getTop() - mChildLayoutParams.topMargin - mDividerWidth;
int right = mChild.getRight() + mChildLayoutParams.rightMargin;
int bottom = mChild.getTop() - mChildLayoutParams.topMargin;
if (isGridLayoutManager(recyclerView)) {
left = mChild.getLeft() - mChildLayoutParams.leftMargin - mDividerWidth;
} else {
left = mChild.getLeft() - mChildLayoutParams.leftMargin;
}
c.drawRect(left, top, right, bottom, mPaint);
}
/**
* 绘制右边分割线
*
* @param c 绘制容器
* @param mChild 对应ItemView
* @param recyclerView RecyclerView
*/
private void drawRight(Canvas c, View mChild, RecyclerView recyclerView) {
RecyclerView.LayoutParams mChildLayoutParams = (RecyclerView.LayoutParams) mChild.getLayoutParams();
int left = mChild.getRight() + mChildLayoutParams.rightMargin;
int top;
int right = left + mDividerWidth;
int bottom = mChild.getBottom() + mChildLayoutParams.bottomMargin;
if (isGridLayoutManager(recyclerView)) {
top = mChild.getTop() - mChildLayoutParams.topMargin - mDividerWidth;
} else {
top = mChild.getTop() - mChildLayoutParams.topMargin;
}
c.drawRect(left, top, right, bottom, mPaint);
}
/**
* 绘制底部分割线
*
* @param c 绘制容器
* @param mChild 对应ItemView
* @param recyclerView RecyclerView
*/
private void drawBottom(Canvas c, View mChild, RecyclerView recyclerView) {
RecyclerView.LayoutParams mChildLayoutParams = (RecyclerView.LayoutParams) mChild.getLayoutParams();
int left = mChild.getLeft() - mChildLayoutParams.leftMargin;
int top = mChild.getBottom() + mChildLayoutParams.bottomMargin;
int bottom = top + mDividerWidth;
int right;
if (isGridLayoutManager(recyclerView)) {
right = mChild.getRight() + mChildLayoutParams.rightMargin + mDividerWidth;
} else {
right = mChild.getRight() + mChildLayoutParams.rightMargin;
}
c.drawRect(left, top, right, bottom, mPaint);
}
/**
* 判断RecyclerView所加载LayoutManager是否为GridLayoutManager
*
* @param recyclerView RecyclerView
* @return 是GridLayoutManager返回true,否则返回false
*/
private boolean isGridLayoutManager(RecyclerView recyclerView) {
RecyclerView.LayoutManager mLayoutManager = recyclerView.getLayoutManager();
return (mLayoutManager instanceof GridLayoutManager);
}
public static class Builer {
int orientation = VERTICAL_DIV;
int color = Color.TRANSPARENT;
int size = 2;
boolean firstLineVisible = false;
public Builer() {
}
public Builer setOrientation(int orientation) {
if (orientation != HORIZONTAL_DIV && orientation != VERTICAL_DIV && orientation != GRID_DIV) {
throw new IllegalArgumentException("ItemDecorationPowerful:分割线类型设置异常");
} else {
this.orientation = orientation;
}
return this;
}
public Builer setColor(int color) {
this.color = color;
return this;
}
public Builer setSize(int size) {
this.size = size;
return this;
}
public Builer setFirstLineVisible(boolean firstLineVisible) {
this.firstLineVisible = firstLineVisible;
return this;
}
public RecyclerViewItemDecoration create() {
return new RecyclerViewItemDecoration(orientation, color, size, firstLineVisible);
}
}
} |
3e093d49298a9e1e05b641e751818175efba76ea | 2,859 | java | Java | SnOOPe/src/presentacion/PanelSnake.java | javier32rojas040506/SnakeVideoGame | 01544539bfd9de031d71d110d9c00f1027268dd7 | [
"CC0-1.0"
] | 4 | 2021-06-07T01:22:07.000Z | 2021-11-15T23:13:14.000Z | SnOOPe/src/presentacion/PanelSnake.java | JuanRojasCastr/SnakeVideoGame | 01544539bfd9de031d71d110d9c00f1027268dd7 | [
"CC0-1.0"
] | null | null | null | SnOOPe/src/presentacion/PanelSnake.java | JuanRojasCastr/SnakeVideoGame | 01544539bfd9de031d71d110d9c00f1027268dd7 | [
"CC0-1.0"
] | 1 | 2021-08-10T17:45:47.000Z | 2021-08-10T17:45:47.000Z | 25.300885 | 109 | 0.633788 | 3,909 | package presentacion;
import aplicacion.*;
import javax.swing.*;
import java.awt.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
public abstract class PanelSnake extends JPanel implements Serializable{
protected final int tamTableroW;
protected final int tamTableroH;
protected final int resW;
protected final int resH;
protected final Color colorSnake;
protected ArrayList<int[]> cuerpoSnake;
protected Alimento[] alimentos;
protected ArrayList<Pared> bloquesTrampa;
protected ArrayList<ProyectilDeFuego> proyectilesDeFuego;
protected SnOOPe snoope;
protected char direccion;
protected char direccionProx;
protected Color colorCabeza;
protected SnOOPeGUI gui;
protected Boolean estado;
protected Boolean pause;
protected Sorpresa sorpresa;
public PanelSnake(Color cuerpo, Color cabeza, int tamMax, int numCuadros, SnOOPe snoope, SnOOPeGUI gui) {
this.gui = gui;
this.snoope = snoope;
setLayout(null);
setOpaque(false);
colorSnake = cuerpo;
colorCabeza = cabeza;
alimentos = snoope.getAlimentos();
int tamMaxW = tamMax - 36;
int tamMaxH = tamMax - 99;
resW = tamMaxW%numCuadros;
resH = tamMaxH%numCuadros;
setBounds(10+(resW/2),30+(resH/2),tamMaxW-(resW),tamMaxH-(resH));
tamTableroW = this.getWidth() /numCuadros;
tamTableroH = this.getHeight() / numCuadros;
estado = true;
pause = false;
repaint();
}
/**
* Metodo getter del estado del juego
* @return si esta vivo o no
*/
public Boolean getEstado() {
return !snoope.getGameOver();
}
/**
* Metodo getter del snoope del juego
* @return si esta vivo o no
*/
public SnOOPe getSnoope() {
return snoope;
}
/**
* Metodo setter del estado de la pausa
*/
public void setPause(Boolean pause) {
this.pause = pause;
}
/**
* Metodo getter del estado del juego
* @return si esta pausado o no
*/
public Boolean getPause() {
return pause;
}
/**
* Metodo getter de los puntos del jugador
* @return la cantidad de putnos
*/
public int getPuntuacion(){return cuerpoSnake.size();}
/**
* Metodo iguala la direcion siguiente y la actual del movimiento
*/
public void igualarDir(){
direccion = direccionProx;
}
/**
* Metodo que permite cambiar la direccion del movimiento
*/
public void cambiarDireccion(char dir){
this.direccionProx = dir;
}
/**
* Setter del snoope
*/
public void setSnoope(SnOOPe snoope) {
this.snoope = snoope;
}
public abstract void mover();
public abstract int veolicidadSerpiente();
}
|
3e093db666a4d4befb6fb189b757de496f044159 | 2,555 | java | Java | jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/config/tables/JoinTableImpl.java | brettdavidson3/eclipselink.runtime | a992a67ce49ca56117df4632c9c0c70938a0b28e | [
"BSD-3-Clause"
] | null | null | null | jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/config/tables/JoinTableImpl.java | brettdavidson3/eclipselink.runtime | a992a67ce49ca56117df4632c9c0c70938a0b28e | [
"BSD-3-Clause"
] | null | null | null | jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/config/tables/JoinTableImpl.java | brettdavidson3/eclipselink.runtime | a992a67ce49ca56117df4632c9c0c70938a0b28e | [
"BSD-3-Clause"
] | 2 | 2020-02-03T09:24:10.000Z | 2021-06-15T13:27:27.000Z | 39.307692 | 105 | 0.695499 | 3,910 | /*******************************************************************************
* Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Guy Pelletier - initial API and implementation
******************************************************************************/
package org.eclipse.persistence.internal.jpa.config.tables;
import java.util.ArrayList;
import org.eclipse.persistence.internal.jpa.config.columns.ForeignKeyImpl;
import org.eclipse.persistence.internal.jpa.config.columns.JoinColumnImpl;
import org.eclipse.persistence.internal.jpa.metadata.columns.JoinColumnMetadata;
import org.eclipse.persistence.internal.jpa.metadata.tables.JoinTableMetadata;
import org.eclipse.persistence.jpa.config.ForeignKey;
import org.eclipse.persistence.jpa.config.JoinColumn;
import org.eclipse.persistence.jpa.config.JoinTable;
/**
* JPA scripting API implementation.
*
* @author Guy Pelletier
* @since EclipseLink 2.5.1
*/
public class JoinTableImpl extends AbstractTableImpl<JoinTableMetadata, JoinTable> implements JoinTable {
public JoinTableImpl() {
super(new JoinTableMetadata());
getMetadata().setJoinColumns(new ArrayList<JoinColumnMetadata>());
getMetadata().setInverseJoinColumns(new ArrayList<JoinColumnMetadata>());
}
public JoinColumn addInverseJoinColumn() {
JoinColumnImpl joinColumn = new JoinColumnImpl();
getMetadata().getInverseJoinColumns().add(joinColumn.getMetadata());
return joinColumn;
}
public JoinColumn addJoinColumn() {
JoinColumnImpl joinColumn = new JoinColumnImpl();
getMetadata().getJoinColumns().add(joinColumn.getMetadata());
return joinColumn;
}
public ForeignKey setForeignKey() {
ForeignKeyImpl foreignKey = new ForeignKeyImpl();
getMetadata().setForeignKey(foreignKey.getMetadata());
return foreignKey;
}
public ForeignKey setInverseForeignKey() {
ForeignKeyImpl foreignKey = new ForeignKeyImpl();
getMetadata().setInverseForeignKey(foreignKey.getMetadata());
return foreignKey;
}
}
|
3e09400c4b6c985a3ccdc0605defa993a92fad3f | 1,473 | java | Java | src/test/java/walkingkooka/collect/iterator/EmptyIteratorTest.java | mP1/walkingkooka | e88f3eee363dcbc4f2c3359309376beb979ca848 | [
"Apache-2.0"
] | 1 | 2018-08-05T00:29:44.000Z | 2018-08-05T00:29:44.000Z | src/test/java/walkingkooka/collect/iterator/EmptyIteratorTest.java | mP1/walkingkooka | e88f3eee363dcbc4f2c3359309376beb979ca848 | [
"Apache-2.0"
] | 320 | 2018-06-27T13:18:41.000Z | 2022-03-06T06:21:54.000Z | src/test/java/walkingkooka/collect/iterator/EmptyIteratorTest.java | mP1/walkingkooka | e88f3eee363dcbc4f2c3359309376beb979ca848 | [
"Apache-2.0"
] | null | null | null | 26.781818 | 90 | 0.695859 | 3,911 | /*
* Copyright 2019 Miroslav Pokorny (github.com/mP1)
*
* 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 walkingkooka.collect.iterator;
import org.junit.jupiter.api.Test;
import walkingkooka.Cast;
final public class EmptyIteratorTest extends IteratorTestCase<EmptyIterator<Void>, Void> {
@Test
public void testHasNext() {
this.hasNextCheckFalse(EmptyIterator.instance());
}
@Test
public void testNext() {
this.nextFails(EmptyIterator.instance());
}
@Test
public void testRemove() {
this.removeWithoutNextFails(EmptyIterator.instance());
}
@Test
public void testToString() {
this.toStringAndCheck(EmptyIterator.instance(), "<empty>");
}
@Override
public EmptyIterator<Void> createIterator() {
return EmptyIterator.instance();
}
@Override
public Class<EmptyIterator<Void>> type() {
return Cast.to(EmptyIterator.class);
}
}
|
3e09427b2206e0f04e7da7b72ac921714f5b4ae5 | 885 | java | Java | src/org/eclipse/jetty/jndi/package-info.java | zogwei/jetty9-learn | 1a1c1af4eefac18e5c0b0b30fd983054ce6dffc9 | [
"Apache-2.0"
] | 1 | 2018-01-23T10:55:11.000Z | 2018-01-23T10:55:11.000Z | jetty-jndi/src/main/java/org/eclipse/jetty/jndi/package-info.java | AjithAnbu/jetty.project-1 | 0b80b9ba36000ea17a72a1691117b20b41097ff8 | [
"Apache-2.0"
] | null | null | null | jetty-jndi/src/main/java/org/eclipse/jetty/jndi/package-info.java | AjithAnbu/jetty.project-1 | 0b80b9ba36000ea17a72a1691117b20b41097ff8 | [
"Apache-2.0"
] | null | null | null | 36.875 | 76 | 0.525424 | 3,912 | //
// ========================================================================
// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
/**
* Jetty Jndi : Java Naming Directory Interface
*/
package org.eclipse.jetty.jndi;
|
3e094358e42b3c93e4ffe1cac310f8b411c36448 | 7,500 | java | Java | java/src/ie/tudublin/Planet.java | Pauleean/SciFiUI | b239c3f202b0fa1892d040549fb553384ab283ed | [
"MIT"
] | null | null | null | java/src/ie/tudublin/Planet.java | Pauleean/SciFiUI | b239c3f202b0fa1892d040549fb553384ab283ed | [
"MIT"
] | null | null | null | java/src/ie/tudublin/Planet.java | Pauleean/SciFiUI | b239c3f202b0fa1892d040549fb553384ab283ed | [
"MIT"
] | null | null | null | 21.186441 | 81 | 0.49 | 3,913 | package ie.tudublin;
import processing.core.PImage;
import processing.data.TableRow;
public class Planet extends DisplayObject
{
PImage img;
boolean scaned;
String name;
float mass;
float iron;
float gold;
float uranium;
String atmosphere;
float temp;
String life;
float water;
float counter;
boolean scanning;
boolean deepScaned;
AbsUI ui2;
public Planet(UI ui, TableRow data)
{
super(ui, data.getFloat("size"), data.getFloat("x"), data.getFloat("y"));
this.name = data.getString("name");
this.mass = data.getFloat("mass");
this.iron = data.getFloat("iron");
this.gold = data.getFloat("gold");
this.uranium = data.getFloat("uranium");
this.water = data.getFloat("water");
this.temp = data.getFloat("temp");
this. life = data.getString("life");
this. atmosphere = data.getString("atmosphere");
img = ui.loadImage(data.getString("Image"));
scaned = false;
scanning = false;
deepScaned = false;
counter = 0;
ui2 = null;
}
//Render Planet to main ui
public void render()
{
//Render image of planet
ui.image(img, pos.x, pos.y, size, size);
//Display Planet fields if planet was scanned
float offset = size/5.0f;
ui.textAlign(UI.CENTER);
if(counter >= 1)
{
ui.text(name, pos.x + (size/2.0f), pos.y - 10);
}
ui.textAlign(UI.RIGHT);
if(counter >= 2)
{
ui.text("Mass: " + mass + "M☉", pos.x - 10, pos.y + offset);
}
if(counter >= 3)
{
ui.text("Iron: " + iron + "%", pos.x - 10, pos.y + (2*offset));
}
if(counter >= 4)
{
ui.text("Gold: " + gold + "%", pos.x - 10, pos.y + (3*offset));
}
if(counter >= 5)
{
ui.text("Uranium: " + uranium + "%", pos.x - 10, pos.y + (4*offset));
}
}
//Display planet to single planet ui
public void renderOrbit(float x, float y, float w)
{
//Render Planet image and name
ui2.image(getImg(), x, y, w, w);
ui2.rect(x, y+w, 250, 100);
ui2.textSize(28);
ui2.text(name, x+125, y+w+50);
ui2.textSize(12);
ui2.text("No technology detected.", x+125, y+w+125);
//Render rectangles for Planet fields
float offset = ui2.height/8.0f;
ui2.strokeWeight(2);
for(int i=0; i<8; i++)
{
ui2.rect(0, i*offset, x, offset);
}
float pos = offset/2.0f;
//Display Planet fields
ui2.text("Mass: " + mass + "M☉", x/2.0f, pos);
pos += offset;
ui2.text("Iron: " + iron + "%", x/2.0f, pos);
pos += offset;
ui2.text("Gold: " + gold + "%", x/2.0f, pos);
pos += offset;
ui2.text("Uranium: " + uranium + "%", x/2.0f, pos);
pos += offset;
//Check if DeepScan has been completed
if(deepScaned)
{
ui2.text("Water: " + water + "%", x/2.0f, pos);
pos += offset;
ui2.text("Tempureture: " + temp + "K", x/2.0f, pos);
pos += offset;
ui2.text("Life signs: " + life, x/2.0f, pos);
pos += offset;
ui2.text("Atmosphere: " + atmosphere, x/2.0f, pos);
}
else
{
ui2.text("Water: ???", x/2.0f, pos);
pos += offset;
ui2.text("Tempureture: ???", x/2.0f, pos);
pos += offset;
ui2.text("Life signs: ???", x/2.0f, pos);
pos += offset;
ui2.text("Atmosphere: ???", x/2.0f, pos);
}
}
public void update()
{
if(scaned && counter < 5)
{
counter += 1/60.0f;
}
}
/**
* @return the img
*/
public PImage getImg() {
return img;
}
/**
* @param img the img to set
*/
public void setImg(PImage img) {
this.img = img;
}
/**
* @return the scaned
*/
public boolean isScaned() {
return scaned;
}
/**
* @param scaned the scaned to set
*/
public void setScaned(boolean scaned) {
this.scaned = scaned;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the mass
*/
public float getMass() {
return mass;
}
/**
* @param mass the mass to set
*/
public void setMass(float mass) {
this.mass = mass;
}
/**
* @return the iron
*/
public float getIron() {
return iron;
}
/**
* @param iron the iron to set
*/
public void setIron(float iron) {
this.iron = iron;
}
/**
* @return the gold
*/
public float getGold() {
return gold;
}
/**
* @param gold the gold to set
*/
public void setGold(float gold) {
this.gold = gold;
}
/**
* @return the uranium
*/
public float getUranium() {
return uranium;
}
/**
* @param uranium the uranium to set
*/
public void setUranium(float uranium) {
this.uranium = uranium;
}
/**
* @return the atmosphere
*/
public String getAtmosphere() {
return atmosphere;
}
/**
* @param atmosphere the atmosphere to set
*/
public void setAtmosphere(String atmosphere) {
this.atmosphere = atmosphere;
}
/**
* @return the temp
*/
public float getTemp() {
return temp;
}
/**
* @param temp the temp to set
*/
public void setTemp(float temp) {
this.temp = temp;
}
/**
* @return the life
*/
public String getLife() {
return life;
}
/**
* @param life the life to set
*/
public void setLife(String life) {
this.life = life;
}
/**
* @return the water
*/
public Float getWater() {
return water;
}
/**
* @param water the water to set
*/
public void setWater(Float water) {
this.water = water;
}
/**
* @return the counter
*/
public float getCounter() {
return counter;
}
/**
* @param counter the counter to set
*/
public void setCounter(float counter) {
this.counter = counter;
}
/**
* @param water the water to set
*/
public void setWater(float water) {
this.water = water;
}
/**
* @return the scanning
*/
public boolean isScanning() {
return scanning;
}
/**
* @param scanning the scanning to set
*/
public void setScanning(boolean scanning) {
this.scanning = scanning;
}
/**
* @return the deepScaned
*/
public boolean isDeepScaned() {
return deepScaned;
}
/**
* @param deepScaned the deepScaned to set
*/
public void setDeepScaned(boolean deepScaned) {
this.deepScaned = deepScaned;
}
/**
* @return the ui2
*/
public AbsUI getUi2() {
return ui2;
}
/**
* @param ui2 the ui2 to set
*/
public void setUi2(AbsUI ui2) {
this.ui2 = ui2;
}
} |
3e0943f48d992ec0e702a357a93f76b55203acd0 | 3,143 | java | Java | src/main/java/com/alipay/api/request/MybankCreditSceneprodCommonQueryRequest.java | wongoo/alipay-sdk-java-all | b3c2dd14a8ffba03a2b96a3dd98e4c4a2a11754b | [
"Apache-2.0"
] | 333 | 2018-08-28T09:26:55.000Z | 2022-03-31T07:26:42.000Z | src/main/java/com/alipay/api/request/MybankCreditSceneprodCommonQueryRequest.java | wongoo/alipay-sdk-java-all | b3c2dd14a8ffba03a2b96a3dd98e4c4a2a11754b | [
"Apache-2.0"
] | 46 | 2018-09-27T03:52:42.000Z | 2021-08-10T07:54:57.000Z | src/main/java/com/alipay/api/request/MybankCreditSceneprodCommonQueryRequest.java | antopen/alipay-sdk-java-all | 790dea41169e764e3f2e08330800246b4aba1b29 | [
"Apache-2.0"
] | 158 | 2018-12-07T17:03:43.000Z | 2022-03-17T09:32:43.000Z | 22.775362 | 122 | 0.70315 | 3,914 | package com.alipay.api.request;
import com.alipay.api.domain.MybankCreditSceneprodCommonQueryModel;
import java.util.Map;
import com.alipay.api.AlipayRequest;
import com.alipay.api.internal.util.AlipayHashMap;
import com.alipay.api.response.MybankCreditSceneprodCommonQueryResponse;
import com.alipay.api.AlipayObject;
/**
* ALIPAY API: mybank.credit.sceneprod.common.query request
*
* @author auto create
* @since 1.0, 2021-07-14 10:10:19
*/
public class MybankCreditSceneprodCommonQueryRequest implements AlipayRequest<MybankCreditSceneprodCommonQueryResponse> {
private AlipayHashMap udfParams; // add user-defined text parameters
private String apiVersion="1.0";
/**
* 场景金融通用查询
*/
private String bizContent;
public void setBizContent(String bizContent) {
this.bizContent = bizContent;
}
public String getBizContent() {
return this.bizContent;
}
private String terminalType;
private String terminalInfo;
private String prodCode;
private String notifyUrl;
private String returnUrl;
private boolean needEncrypt=false;
private AlipayObject bizModel=null;
public String getNotifyUrl() {
return this.notifyUrl;
}
public void setNotifyUrl(String notifyUrl) {
this.notifyUrl = notifyUrl;
}
public String getReturnUrl() {
return this.returnUrl;
}
public void setReturnUrl(String returnUrl) {
this.returnUrl = returnUrl;
}
public String getApiVersion() {
return this.apiVersion;
}
public void setApiVersion(String apiVersion) {
this.apiVersion = apiVersion;
}
public void setTerminalType(String terminalType){
this.terminalType=terminalType;
}
public String getTerminalType(){
return this.terminalType;
}
public void setTerminalInfo(String terminalInfo){
this.terminalInfo=terminalInfo;
}
public String getTerminalInfo(){
return this.terminalInfo;
}
public void setProdCode(String prodCode) {
this.prodCode=prodCode;
}
public String getProdCode() {
return this.prodCode;
}
public String getApiMethodName() {
return "mybank.credit.sceneprod.common.query";
}
public Map<String, String> getTextParams() {
AlipayHashMap txtParams = new AlipayHashMap();
txtParams.put("biz_content", this.bizContent);
if(udfParams != null) {
txtParams.putAll(this.udfParams);
}
return txtParams;
}
public void putOtherTextParam(String key, String value) {
if(this.udfParams == null) {
this.udfParams = new AlipayHashMap();
}
this.udfParams.put(key, value);
}
public Class<MybankCreditSceneprodCommonQueryResponse> getResponseClass() {
return MybankCreditSceneprodCommonQueryResponse.class;
}
public boolean isNeedEncrypt() {
return this.needEncrypt;
}
public void setNeedEncrypt(boolean needEncrypt) {
this.needEncrypt=needEncrypt;
}
public AlipayObject getBizModel() {
return this.bizModel;
}
public void setBizModel(AlipayObject bizModel) {
this.bizModel=bizModel;
}
}
|
3e09447f34291e3f3d1ec4f87c63e4617b720002 | 251 | java | Java | src/main/java/org/fis/student/exceptions/DestinationAndDateUsedException.java | fis2021/Travel_Agency | e58b425bd5cc32c59c1d2e93ac1e30b68524a546 | [
"Apache-2.0"
] | null | null | null | src/main/java/org/fis/student/exceptions/DestinationAndDateUsedException.java | fis2021/Travel_Agency | e58b425bd5cc32c59c1d2e93ac1e30b68524a546 | [
"Apache-2.0"
] | null | null | null | src/main/java/org/fis/student/exceptions/DestinationAndDateUsedException.java | fis2021/Travel_Agency | e58b425bd5cc32c59c1d2e93ac1e30b68524a546 | [
"Apache-2.0"
] | null | null | null | 31.375 | 94 | 0.752988 | 3,915 | package org.fis.student.exceptions;
public class DestinationAndDateUsedException extends Exception{
public DestinationAndDateUsedException() {
super(String.format("You can't add a new trip with the same destination and date !"));
}
}
|
3e0944fbcc5c07887ed2c93b379225f6e129ee00 | 17,647 | java | Java | app/src/main/java/jp/sblo/pandora/jota/ActivityPicker.java | anonymous1999/JotaTextEditor | b75f20249f2631943ba6b1413ad130eb388e7860 | [
"Apache-2.0"
] | 53 | 2016-03-03T09:11:42.000Z | 2022-02-18T20:28:44.000Z | app/src/main/java/jp/sblo/pandora/jota/ActivityPicker.java | maoabc/JotaTextEditor | 094fa601566ab9488210b72a12be6f845b01d00a | [
"Apache-2.0"
] | 5 | 2016-10-23T12:40:43.000Z | 2021-12-27T17:49:31.000Z | app/src/main/java/jp/sblo/pandora/jota/ActivityPicker.java | maoabc/JotaTextEditor | 094fa601566ab9488210b72a12be6f845b01d00a | [
"Apache-2.0"
] | 22 | 2016-01-25T07:36:17.000Z | 2021-12-15T18:02:55.000Z | 36.3107 | 99 | 0.575225 | 3,916 | /*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jp.sblo.pandora.jota;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.Intent.ShortcutIconResource;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.PaintDrawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.android.internal.app.AlertActivity;
import com.android.internal.app.AlertController;
/**
* Displays a list of all activities matching the incoming
* {@link Intent#EXTRA_INTENT} query, along with any injected items.
*/
public class ActivityPicker extends AlertActivity implements
DialogInterface.OnClickListener, DialogInterface.OnCancelListener {
public final static String EXTRA_APPNAME = "jota_text_editor_extra_appname";
/**
* Adapter of items that are displayed in this dialog.
*/
private PickAdapter mAdapter;
/**
* Base {@link Intent} used when building list.
*/
private Intent mBaseIntent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Intent intent = getIntent();
// Read base intent from extras, otherwise assume default
Parcelable parcel = intent.getParcelableExtra(Intent.EXTRA_INTENT);
if (parcel instanceof Intent) {
mBaseIntent = (Intent) parcel;
} else {
mBaseIntent = new Intent(Intent.ACTION_MAIN, null);
mBaseIntent.addCategory(Intent.CATEGORY_DEFAULT);
}
// Create dialog parameters
AlertController.AlertParams params = mAlertParams;
params.mOnClickListener = this;
params.mOnCancelListener = this;
// Use custom title if provided, otherwise default window title
if (intent.hasExtra(Intent.EXTRA_TITLE)) {
params.mTitle = intent.getStringExtra(Intent.EXTRA_TITLE);
} else {
params.mTitle = getTitle();
}
// Build list adapter of pickable items
List<PickAdapter.Item> items = getItems();
if ( items != null ){
mAdapter = new PickAdapter(this, items);
params.mAdapter = mAdapter;
setupAlert();
}else{
setResult(Activity.RESULT_FIRST_USER);
finish();
}
}
/**
* Handle clicking of dialog item by passing back
* {@link #getIntentForPosition(int)} in {@link #setResult(int, Intent)}.
*/
public void onClick(DialogInterface dialog, int which) {
Intent intent = getIntentForPosition(which);
setResult(Activity.RESULT_OK, intent);
finish();
}
/**
* Handle canceled dialog by passing back {@link Activity#RESULT_CANCELED}.
*/
public void onCancel(DialogInterface dialog) {
setResult(Activity.RESULT_CANCELED);
finish();
}
/**
* Build the specific {@link Intent} for a given list position. Convenience
* method that calls through to {@link PickAdapter.Item#getIntent(Intent)}.
*/
protected Intent getIntentForPosition(int position) {
PickAdapter.Item item = (PickAdapter.Item) mAdapter.getItem(position);
return item.getIntent(mBaseIntent);
}
/**
* Build and return list of items to be shown in dialog. Default
* implementation mixes activities matching {@link #mBaseIntent} from
* {@link #putIntentItems(Intent, List)} with any injected items from
* {@link Intent#EXTRA_SHORTCUT_NAME}. Override this method in subclasses to
* change the items shown.
*/
protected List<PickAdapter.Item> getItems() {
PackageManager packageManager = getPackageManager();
List<PickAdapter.Item> items = new ArrayList<PickAdapter.Item>();
// Add any injected pick items
final Intent intent = getIntent();
ArrayList<String> labels =
intent.getStringArrayListExtra(Intent.EXTRA_SHORTCUT_NAME);
ArrayList<ShortcutIconResource> icons =
intent.getParcelableArrayListExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
if (labels != null && icons != null && labels.size() == icons.size()) {
for (int i = 0; i < labels.size(); i++) {
String label = labels.get(i);
Drawable icon = null;
try {
// Try loading icon from requested package
ShortcutIconResource iconResource = icons.get(i);
Resources res = packageManager.getResourcesForApplication(
iconResource.packageName);
icon = res.getDrawable(res.getIdentifier(
iconResource.resourceName, null, null));
} catch (NameNotFoundException e) {
// Ignore
}
items.add(new PickAdapter.Item(this, label, icon));
}
}
// Add any intent items if base was given
if (mBaseIntent != null) {
putIntentItems(mBaseIntent, items);
}
if ( items.size() == 0 ){
return null;
}
return items;
}
/**
* Fill the given list with any activities matching the base {@link Intent}.
*/
protected void putIntentItems(Intent baseIntent, List<PickAdapter.Item> items) {
PackageManager packageManager = getPackageManager();
List<ResolveInfo> list = packageManager.queryIntentActivities(baseIntent,
0 /* no flags */);
Collections.sort(list, new ResolveInfo.DisplayNameComparator(packageManager));
final int listSize = list.size();
for (int i = 0; i < listSize; i++) {
ResolveInfo resolveInfo = list.get(i);
items.add(new PickAdapter.Item(this, packageManager, resolveInfo));
}
}
/**
* Adapter which shows the set of activities that can be performed for a
* given {@link Intent}.
*/
protected static class PickAdapter extends BaseAdapter {
/**
* Item that appears in a {@link PickAdapter} list.
*/
public static class Item {
protected static IconResizer sResizer;
protected IconResizer getResizer(Context context) {
if (sResizer == null) {
final Resources resources = context.getResources();
int size = (int) resources.getDimension(R.dimen.app_icon_size);
sResizer = new IconResizer(size, size, resources.getDisplayMetrics());
}
return sResizer;
}
CharSequence label;
Drawable icon;
String packageName;
String className;
Bundle extras;
/**
* Create a list item from given label and icon.
*/
Item(Context context, CharSequence label, Drawable icon) {
this.label = label;
this.icon = getResizer(context).createIconThumbnail(icon);
}
/**
* Create a list item and fill it with details from the given
* {@link ResolveInfo} object.
*/
Item(Context context, PackageManager pm, ResolveInfo resolveInfo) {
label = resolveInfo.loadLabel(pm);
if (label == null && resolveInfo.activityInfo != null) {
label = resolveInfo.activityInfo.name;
}
icon = getResizer(context).createIconThumbnail(resolveInfo.loadIcon(pm));
packageName = resolveInfo.activityInfo.applicationInfo.packageName;
className = resolveInfo.activityInfo.name;
}
/**
* Build the {@link Intent} described by this item. If this item
* can't create a valid {@link android.content.ComponentName}, it will return
* {@link Intent#ACTION_CREATE_SHORTCUT} filled with the item label.
*/
Intent getIntent(Intent baseIntent) {
Intent intent = new Intent(baseIntent);
if (packageName != null && className != null) {
// Valid package and class, so fill details as normal intent
intent.setClassName(packageName, className);
if (extras != null) {
intent.putExtras(extras);
}
} else {
// No valid package or class, so treat as shortcut with label
intent.setAction(Intent.ACTION_CREATE_SHORTCUT);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label);
}
intent.putExtra( EXTRA_APPNAME ,label );
return intent;
}
}
private final LayoutInflater mInflater;
private final List<Item> mItems;
/**
* Create an adapter for the given items.
*/
public PickAdapter(Context context, List<Item> items) {
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mItems = items;
}
/**
* {@inheritDoc}
*/
public int getCount() {
return mItems.size();
}
/**
* {@inheritDoc}
*/
public Object getItem(int position) {
return mItems.get(position);
}
/**
* {@inheritDoc}
*/
public long getItemId(int position) {
return position;
}
/**
* {@inheritDoc}
*/
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.pick_item, parent, false);
}
Item item = (Item) getItem(position);
TextView textView = (TextView) convertView;
textView.setText(item.label);
textView.setCompoundDrawablesWithIntrinsicBounds(item.icon, null, null, null);
return convertView;
}
}
/**
* Utility class to resize icons to match default icon size. Code is mostly
* borrowed from Launcher.
*/
private static class IconResizer {
private final int mIconWidth;
private final int mIconHeight;
private final DisplayMetrics mMetrics;
private final Rect mOldBounds = new Rect();
private final Canvas mCanvas = new Canvas();
public IconResizer(int width, int height, DisplayMetrics metrics) {
mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
Paint.FILTER_BITMAP_FLAG));
mMetrics = metrics;
mIconWidth = width;
mIconHeight = height;
}
/**
* Returns a Drawable representing the thumbnail of the specified Drawable.
* The size of the thumbnail is defined by the dimension
* android.R.dimen.launcher_application_icon_size.
*
* This method is not thread-safe and should be invoked on the UI thread only.
*
* @param icon The icon to get a thumbnail of.
*
* @return A thumbnail for the specified icon or the icon itself if the
* thumbnail could not be created.
*/
@SuppressWarnings("deprecation")
public Drawable createIconThumbnail(Drawable icon) {
int width = mIconWidth;
int height = mIconHeight;
if (icon == null) {
return new EmptyDrawable(width, height);
}
try {
if (icon instanceof PaintDrawable) {
PaintDrawable painter = (PaintDrawable) icon;
painter.setIntrinsicWidth(width);
painter.setIntrinsicHeight(height);
} else if (icon instanceof BitmapDrawable) {
// Ensure the bitmap has a density.
BitmapDrawable bitmapDrawable = (BitmapDrawable) icon;
Bitmap bitmap = bitmapDrawable.getBitmap();
if (bitmap.getDensity() == Bitmap.DENSITY_NONE) {
bitmapDrawable.setTargetDensity(mMetrics);
}
}
int iconWidth = icon.getIntrinsicWidth();
int iconHeight = icon.getIntrinsicHeight();
if (iconWidth > 0 && iconHeight > 0) {
if (width < iconWidth || height < iconHeight) {
final float ratio = (float) iconWidth / iconHeight;
if (iconWidth > iconHeight) {
height = (int) (width / ratio);
} else if (iconHeight > iconWidth) {
width = (int) (height * ratio);
}
final Bitmap.Config c = icon.getOpacity() != PixelFormat.OPAQUE ?
Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
final Bitmap thumb = Bitmap.createBitmap(mIconWidth, mIconHeight, c);
final Canvas canvas = mCanvas;
canvas.setBitmap(thumb);
// Copy the old bounds to restore them later
// If we were to do oldBounds = icon.getBounds(),
// the call to setBounds() that follows would
// change the same instance and we would lose the
// old bounds
mOldBounds.set(icon.getBounds());
final int x = (mIconWidth - width) / 2;
final int y = (mIconHeight - height) / 2;
icon.setBounds(x, y, x + width, y + height);
icon.draw(canvas);
icon.setBounds(mOldBounds);
//noinspection deprecation
icon = new BitmapDrawable(thumb);
((BitmapDrawable) icon).setTargetDensity(mMetrics);
} else if (iconWidth < width && iconHeight < height) {
final Bitmap.Config c = Bitmap.Config.ARGB_8888;
final Bitmap thumb = Bitmap.createBitmap(mIconWidth, mIconHeight, c);
final Canvas canvas = mCanvas;
canvas.setBitmap(thumb);
mOldBounds.set(icon.getBounds());
final int x = (width - iconWidth) / 2;
final int y = (height - iconHeight) / 2;
icon.setBounds(x, y, x + iconWidth, y + iconHeight);
icon.draw(canvas);
icon.setBounds(mOldBounds);
//noinspection deprecation
icon = new BitmapDrawable(thumb);
((BitmapDrawable) icon).setTargetDensity(mMetrics);
}
}
} catch (Throwable t) {
icon = new EmptyDrawable(width, height);
}
return icon;
}
}
private static class EmptyDrawable extends Drawable {
private final int mWidth;
private final int mHeight;
EmptyDrawable(int width, int height) {
mWidth = width;
mHeight = height;
}
@Override
public int getIntrinsicWidth() {
return mWidth;
}
@Override
public int getIntrinsicHeight() {
return mHeight;
}
@Override
public int getMinimumWidth() {
return mWidth;
}
@Override
public int getMinimumHeight() {
return mHeight;
}
@Override
public void draw(Canvas canvas) {
}
@Override
public void setAlpha(int alpha) {
}
@Override
public void setColorFilter(ColorFilter cf) {
}
@Override
public int getOpacity() {
return PixelFormat.TRANSLUCENT;
}
}
}
|
3e0945648ecfcb6286fed89421f69b9378ff7496 | 795 | java | Java | http-client/src/main/java/be/tombaeyens/magicless/httpclient/Serializer.java | tombaeyens/magicless | 2f40599313fe4cbc9263c6a931cf69bc5e04c6fd | [
"Apache-2.0"
] | null | null | null | http-client/src/main/java/be/tombaeyens/magicless/httpclient/Serializer.java | tombaeyens/magicless | 2f40599313fe4cbc9263c6a931cf69bc5e04c6fd | [
"Apache-2.0"
] | null | null | null | http-client/src/main/java/be/tombaeyens/magicless/httpclient/Serializer.java | tombaeyens/magicless | 2f40599313fe4cbc9263c6a931cf69bc5e04c6fd | [
"Apache-2.0"
] | null | null | null | 30.576923 | 75 | 0.74717 | 3,917 | /*
* Copyright (c) 2018 Tom Baeyens
*
* 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 be.tombaeyens.magicless.httpclient;
import java.lang.reflect.Type;
public interface Serializer {
String serialize(Object jsonObject);
Object deserialize(String body, Type type);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.