hexsha
stringlengths
40
40
size
int64
8
1.04M
content
stringlengths
8
1.04M
avg_line_length
float64
2.24
100
max_line_length
int64
4
1k
alphanum_fraction
float64
0.25
0.97
61f02b6a64e37fef09e9a3834924e87308a64768
6,007
package com.zust.itee.exam.dto; import java.util.Date; /** * 全部驾驶员首页 * @author liy * */ public class DriverIndex { private Integer id; private String org_name; private String name; private String birthPlace; private Date birth; private String gen; private String sfzNo; private String photo; private String address; private String postcode; private String mobile; private String password; private String email; private String emergencyContact; private String emergencyContactMobile; private String driveLicenceNo; private String driveLincencePhoto; private Date driveLicenceStartTime; private Date driveLicenceEndTime; private String safeCentificateNo; private String safeCentificatePhoto; private Date safeCentificateStartTime; private Date safeCentificateEndTime; private short status; //-2 不可用-1->删除;0->待审核;1->可用 (可能会增加状态) public DriverIndex() { // TODO Auto-generated constructor stub } public DriverIndex(Integer id,String org_name, String name, String birthPlace, String gen, String sfzNo, String mobile, String driveLicenceNo) { this.id = id; this.org_name = org_name; this.name = name; this.birthPlace = birthPlace; this.gen = gen; this.sfzNo = sfzNo; this.mobile = mobile; this.driveLicenceNo = driveLicenceNo; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getOrg_name() { return org_name; } public void setOrg_name(String org_name) { this.org_name = org_name; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getBirthPlace() { return birthPlace; } public void setBirthPlace(String birthPlace) { this.birthPlace = birthPlace; } public Date getBirth() { return birth; } public void setBirth(Date birth) { this.birth = birth; } public String getGen() { return gen; } public void setGen(String gen) { this.gen = gen; } public String getSfzNo() { return sfzNo; } public void setSfzNo(String sfzNo) { this.sfzNo = sfzNo; } public String getPhoto() { return photo; } public void setPhoto(String photo) { this.photo = photo; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getPostcode() { return postcode; } public void setPostcode(String postcode) { this.postcode = postcode; } public String getMobile() { return mobile; } public void setMobile(String mobile) { this.mobile = mobile; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getEmergencyContact() { return emergencyContact; } public void setEmergencyContact(String emergencyContact) { this.emergencyContact = emergencyContact; } public String getEmergencyContactMobile() { return emergencyContactMobile; } public void setEmergencyContactMobile(String emergencyContactMobile) { this.emergencyContactMobile = emergencyContactMobile; } public String getDriveLicenceNo() { return driveLicenceNo; } public void setDriveLicenceNo(String driveLicenceNo) { this.driveLicenceNo = driveLicenceNo; } public String getDriveLincencePhoto() { return driveLincencePhoto; } public void setDriveLincencePhoto(String driveLincencePhoto) { this.driveLincencePhoto = driveLincencePhoto; } public Date getDriveLicenceStartTime() { return driveLicenceStartTime; } public void setDriveLicenceStartTime(Date driveLicenceStartTime) { this.driveLicenceStartTime = driveLicenceStartTime; } public Date getDriveLicenceEndTime() { return driveLicenceEndTime; } public void setDriveLicenceEndTime(Date driveLicenceEndTime) { this.driveLicenceEndTime = driveLicenceEndTime; } public String getSafeCentificateNo() { return safeCentificateNo; } public void setSafeCentificateNo(String safeCentificateNo) { this.safeCentificateNo = safeCentificateNo; } public String getSafeCentificatePhoto() { return safeCentificatePhoto; } public void setSafeCentificatePhoto(String safeCentificatePhoto) { this.safeCentificatePhoto = safeCentificatePhoto; } public Date getSafeCentificateStartTime() { return safeCentificateStartTime; } public void setSafeCentificateStartTime(Date safeCentificateStartTime) { this.safeCentificateStartTime = safeCentificateStartTime; } public Date getSafeCentificateEndTime() { return safeCentificateEndTime; } public void setSafeCentificateEndTime(Date safeCentificateEndTime) { this.safeCentificateEndTime = safeCentificateEndTime; } public short getStatus() { return status; } public void setStatus(short status) { this.status = status; } @Override public String toString() { return "DriverIndex{" + "id=" + id + ", org_name='" + org_name + '\'' + ", name='" + name + '\'' + ", birthPlace='" + birthPlace + '\'' + ", birth=" + birth + ", gen='" + gen + '\'' + ", sfzNo='" + sfzNo + '\'' + ", photo='" + photo + '\'' + ", address='" + address + '\'' + ", postcode='" + postcode + '\'' + ", mobile='" + mobile + '\'' + ", password='" + password + '\'' + ", email='" + email + '\'' + ", emergencyContact='" + emergencyContact + '\'' + ", emergencyContactMobile='" + emergencyContactMobile + '\'' + ", driveLicenceNo='" + driveLicenceNo + '\'' + ", driveLincencePhoto='" + driveLincencePhoto + '\'' + ", driveLicenceStartTime=" + driveLicenceStartTime + ", driveLicenceEndTime=" + driveLicenceEndTime + ", safeCentificateNo='" + safeCentificateNo + '\'' + ", safeCentificatePhoto='" + safeCentificatePhoto + '\'' + ", safeCentificateStartTime=" + safeCentificateStartTime + ", safeCentificateEndTime=" + safeCentificateEndTime + ", status=" + status + '}'; } }
21.607914
79
0.709672
78c941a1075f9966703719d76999eb82c3eb263f
3,035
package de.hub.mse.ttc2020.solution.M2; import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeListener; import java.util.Objects; public class Person { protected PropertyChangeSupport listeners; public static final String PROPERTY_id = "id"; private String id; public static final String PROPERTY_name = "name"; private String name; public static final String PROPERTY_ybirth = "ybirth"; private int ybirth; public boolean firePropertyChange(String propertyName, Object oldValue, Object newValue) { if (this.listeners != null) { this.listeners.firePropertyChange(propertyName, oldValue, newValue); return true; } return false; } public boolean addPropertyChangeListener(PropertyChangeListener listener) { if (this.listeners == null) { this.listeners = new PropertyChangeSupport(this); } this.listeners.addPropertyChangeListener(listener); return true; } public boolean addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { if (this.listeners == null) { this.listeners = new PropertyChangeSupport(this); } this.listeners.addPropertyChangeListener(propertyName, listener); return true; } public boolean removePropertyChangeListener(PropertyChangeListener listener) { if (this.listeners != null) { this.listeners.removePropertyChangeListener(listener); } return true; } public boolean removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { if (this.listeners != null) { this.listeners.removePropertyChangeListener(propertyName, listener); } return true; } @Override public String toString() { final StringBuilder result = new StringBuilder(); result.append(' ').append(this.getId()); result.append(' ').append(this.getName()); return result.substring(1); } public String getId() { return this.id; } public Person setId(String value) { if (Objects.equals(value, this.id)) { return this; } final String oldValue = this.id; this.id = value; this.firePropertyChange(PROPERTY_id, oldValue, value); return this; } public String getName() { return this.name; } public Person setName(String value) { if (Objects.equals(value, this.name)) { return this; } final String oldValue = this.name; this.name = value; this.firePropertyChange(PROPERTY_name, oldValue, value); return this; } public int getYbirth() { return this.ybirth; } public Person setYbirth(int value) { if (value == this.ybirth) { return this; } final int oldValue = this.ybirth; this.ybirth = value; this.firePropertyChange(PROPERTY_ybirth, oldValue, value); return this; } }
23.710938
100
0.650082
755cc5ca3ad9ab0464fe9d59fbbe91684446bd5e
1,133
package com.reptile.util; import java.util.HashSet; import java.util.Set; public class LinkQueue { //已访问的URL集合 private static Set visitedUrl = new HashSet(); //待访问的URL集合 private static Queue unVisitedUrl = new Queue(); //获得URL队列 public static Queue getUnVisitedUrl () { return unVisitedUrl; } //添加到访问的URL队列中 public static void addVisitedUrl (String url) { visitedUrl.add(url); } //移除访问过的URL public static void removeVisitedUrl (String url) { visitedUrl.remove(url); } //未访问的URL出队列 public static Object unVisitedUrlDeQueue () { return unVisitedUrl.deQueue(); } //保证每个URL只访问一次 public static void addUnvisitedUrl (String url) { if (url != null && !url.trim().equals("") && !visitedUrl.contains(url) && !unVisitedUrl.contains(url)) { unVisitedUrl.enQueue(url); } } //获得已经访问的URL数目 public static int getVisitedUrlNum () { return visitedUrl.size(); } //判断未访问过得URL队列中是否为空 public static boolean unVisitedUrlIsEmpty () { return unVisitedUrl.empty(); } }
21.377358
112
0.631951
066de34b83877586e4ee8f6d7e37204f2c1b1798
90,736
package mtr.model; import mtr.render.MoreRenderLayers; import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; public class ModelSP1900 extends ModelTrainBase { private final ModelPart window; private final ModelPart upper_wall_r1; private final ModelPart seat; private final ModelPart seat_back_c1141a_r1; private final ModelPart window_exterior_1; private final ModelPart upper_wall_r2; private final ModelPart window_exterior_2; private final ModelPart upper_wall_r3; private final ModelPart side_panel_sp1900; private final ModelPart handrail_7_r1; private final ModelPart handrail_6_r1; private final ModelPart handrail_4_r1; private final ModelPart handrail_3_r1; private final ModelPart handrail_2_r1; private final ModelPart side_panel_c1141a; private final ModelPart handrail_5_r1; private final ModelPart handrail_3_r2; private final ModelPart door; private final ModelPart door_left; private final ModelPart door_left_top_r1; private final ModelPart door_right; private final ModelPart door_right_top_r1; private final ModelPart door_light_c1141a; private final ModelPart door_exterior_1; private final ModelPart door_right_exterior_1; private final ModelPart door_left_top_r2; private final ModelPart door_left_exterior_1; private final ModelPart door_right_top_r2_r1; private final ModelPart door_exterior_2; private final ModelPart door_left_exterior_2; private final ModelPart door_left_top_r3; private final ModelPart door_right_exterior_2; private final ModelPart door_right_top_r3_r1; private final ModelPart end; private final ModelPart upper_wall_2_r1; private final ModelPart upper_wall_1_r1; private final ModelPart seat_end_1; private final ModelPart seat_back_1_c1141a_r1; private final ModelPart seat_end_2; private final ModelPart seat_back_2_c1141a_r1; private final ModelPart seat_bottom_2_r1; private final ModelPart end_exterior; private final ModelPart outer_roof_2_r1; private final ModelPart outer_roof_1_r1; private final ModelPart floor_1_r1; private final ModelPart roof_sp1900; private final ModelPart inner_roof_6_r1; private final ModelPart inner_roof_5_r1; private final ModelPart inner_roof_4_r1; private final ModelPart inner_roof_3_r1; private final ModelPart inner_roof_2_r1; private final ModelPart roof_c1141a; private final ModelPart inner_roof_3_r2; private final ModelPart roof_exterior; private final ModelPart outer_roof_4_r1; private final ModelPart outer_roof_3_r1; private final ModelPart outer_roof_2_r2; private final ModelPart outer_roof_1_r2; private final ModelPart roof_light_sp1900; private final ModelPart light_3_r1; private final ModelPart light_1_r1; private final ModelPart roof_light_c1141a; private final ModelPart roof_end_sp1900; private final ModelPart inner_roof_1; private final ModelPart inner_roof_6_r2; private final ModelPart inner_roof_5_r2; private final ModelPart inner_roof_4_r2; private final ModelPart inner_roof_3_r3; private final ModelPart inner_roof_2_r2; private final ModelPart inner_roof_2; private final ModelPart inner_roof_6_r3; private final ModelPart inner_roof_5_r3; private final ModelPart inner_roof_4_r3; private final ModelPart inner_roof_3_r4; private final ModelPart inner_roof_2_r3; private final ModelPart roof_end_c1141a; private final ModelPart inner_roof_3; private final ModelPart inner_roof_3_r5; private final ModelPart inner_roof_4; private final ModelPart inner_roof_3_r6; private final ModelPart roof_end_exterior; private final ModelPart vent_2_r1; private final ModelPart vent_1_r1; private final ModelPart outer_roof_1; private final ModelPart outer_roof_3_r2; private final ModelPart outer_roof_2_r3; private final ModelPart outer_roof_2; private final ModelPart outer_roof_3_r3; private final ModelPart outer_roof_2_r4; private final ModelPart roof_end_light_sp1900; private final ModelPart light_6_r1; private final ModelPart light_4_r1; private final ModelPart light_3_r2; private final ModelPart light_1_r2; private final ModelPart roof_end_light_c1141a; private final ModelPart top_handrail_sp1900; private final ModelPart top_handrail_bottom_right_r1; private final ModelPart top_handrail_bottom_left_r1; private final ModelPart top_handrail_right_3_r1; private final ModelPart top_handrail_right_2_r1; private final ModelPart top_handrail_left_3_r1; private final ModelPart top_handrail_left_2_r1; private final ModelPart handrail_strap_1; private final ModelPart top_handrail_c1141a; private final ModelPart pole_bottom_diagonal_2_r1; private final ModelPart pole_bottom_diagonal_1_r1; private final ModelPart pole_top_diagonal_2_r1; private final ModelPart pole_top_diagonal_1_r1; private final ModelPart top_handrail_connector_bottom_4_r1; private final ModelPart top_handrail_connector_bottom_3_r1; private final ModelPart top_handrail_bottom_right_r2; private final ModelPart top_handrail_bottom_left_r2; private final ModelPart top_handrail_right_4_r1; private final ModelPart top_handrail_right_3_r2; private final ModelPart top_handrail_left_4_r1; private final ModelPart top_handrail_left_3_r2; private final ModelPart handrail_strap_2; private final ModelPart handrail_strap_8_r1; private final ModelPart tv_pole; private final ModelPart tv_right_r1; private final ModelPart tv_left_r1; private final ModelPart pole_5_r1; private final ModelPart pole_4_r1; private final ModelPart pole_2_r1; private final ModelPart pole_1_r1; private final ModelPart head; private final ModelPart upper_wall_2_r2; private final ModelPart upper_wall_1_r2; private final ModelPart seat_head_1; private final ModelPart seat_back_c1141a_r2; private final ModelPart seat_head_2; private final ModelPart seat_back_c1141a_r3; private final ModelPart seat_bottom_r1; private final ModelPart head_exterior; private final ModelPart outer_roof_1_r3; private final ModelPart outer_roof_2_r5; private final ModelPart driver_door_top_2_r1; private final ModelPart driver_door_top_1_r1; private final ModelPart floor_2_r1; private final ModelPart front; private final ModelPart front_middle_r1_r1; private final ModelPart front_roof_r1_r1; private final ModelPart bottom_r1_r1; private final ModelPart front_bottom_r1_r1; private final ModelPart front_side_1_r1_r1; private final ModelPart front_side_2_r1_r1; private final ModelPart bottom_side_1_r1_r1; private final ModelPart bottom_side_2_r1_r1; private final ModelPart top_side_1_r1_r1; private final ModelPart top_side_2_r1_r1; private final ModelPart roof_side_1_r1_r1; private final ModelPart roof_side_2_r1_r1; private final ModelPart roof_middle_corner_1_r1_r1; private final ModelPart roof_middle_corner_2_r1_r1; private final ModelPart roof_corner_1_r1_r1; private final ModelPart roof_corner_2_r1_r1; private final ModelPart bottom_corner_1_r1_r1; private final ModelPart bottom_corner_2_r1_r1; private final ModelPart top_handrail_head_sp1900; private final ModelPart top_handrail_bottom_left_r3; private final ModelPart top_handrail_bottom_right_r3; private final ModelPart top_handrail_right_3_r3; private final ModelPart top_handrail_right_2_r2; private final ModelPart top_handrail_left_3_r3; private final ModelPart top_handrail_left_2_r2; private final ModelPart handrail_strap_head; private final ModelPart top_handrail_head_c1141a; private final ModelPart pole_bottom_diagonal_3_r1; private final ModelPart pole_bottom_diagonal_2_r2; private final ModelPart pole_top_diagonal_3_r1; private final ModelPart pole_top_diagonal_2_r2; private final ModelPart top_handrail_connector_bottom_5_r1; private final ModelPart top_handrail_connector_bottom_right_4_r1; private final ModelPart top_handrail_connector_bottom_left_4_r1; private final ModelPart top_handrail_connector_bottom_right_3_r1; private final ModelPart top_handrail_connector_bottom_left_3_r1; private final ModelPart top_handrail_bottom_right_r4; private final ModelPart top_handrail_right_5_r1; private final ModelPart top_handrail_right_4_r2; private final ModelPart top_handrail_left_5_r1; private final ModelPart top_handrail_left_4_r2; private final ModelPart handrail_strap_3; private final ModelPart handrail_strap_right_8_r1; private final ModelPart handrail_strap_left_8_r1; private final ModelPart headlights; private final ModelPart headlight_4_r1_r1; private final ModelPart headlight_3_r1_r1; private final ModelPart headlight_1_r1_r1; private final ModelPart tail_lights; private final ModelPart tail_light_4_r1_r1; private final ModelPart tail_light_3_r1_r1; private final ModelPart tail_light_1_r1_r1; private final ModelPart bb_main; private final boolean isC1141A; public ModelSP1900(boolean isC1141A) { this.isC1141A = isC1141A; textureWidth = 416; textureHeight = 416; window = new ModelPart(this); window.setPivot(0.0F, 24.0F, 0.0F); window.setTextureOffset(58, 115).addCuboid(-20.0F, 0.0F, -16.0F, 20.0F, 1.0F, 32.0F, 0.0F, false); window.setTextureOffset(326, 119).addCuboid(-20.0F, -14.0F, -18.0F, 2.0F, 14.0F, 36.0F, 0.0F, false); upper_wall_r1 = new ModelPart(this); upper_wall_r1.setPivot(-20.0F, -14.0F, 0.0F); window.addChild(upper_wall_r1); setRotationAngle(upper_wall_r1, 0.0F, 0.0F, 0.1107F); upper_wall_r1.setTextureOffset(134, 311).addCuboid(0.0F, -19.0F, -18.0F, 2.0F, 19.0F, 36.0F, 0.0F, false); seat = new ModelPart(this); seat.setPivot(-9.0F, 0.0F, 0.0F); window.addChild(seat); seat.setTextureOffset(228, 192).addCuboid(-9.0F, -6.0F, -16.0F, 7.0F, 1.0F, 32.0F, 0.0F, false); seat_back_c1141a_r1 = new ModelPart(this); seat_back_c1141a_r1.setPivot(-9.0F, -6.5F, 0.0F); seat.addChild(seat_back_c1141a_r1); setRotationAngle(seat_back_c1141a_r1, 0.0F, 0.0F, -0.0873F); seat_back_c1141a_r1.setTextureOffset(254, 71).addCuboid(0.0F, -6.0F, -12.0F, 1.0F, 4.0F, 24.0F, 0.0F, false); seat_back_c1141a_r1.setTextureOffset(212, 351).addCuboid(0.0F, -8.0F, -16.0F, 1.0F, 8.0F, 32.0F, 0.0F, false); window_exterior_1 = new ModelPart(this); window_exterior_1.setPivot(0.0F, 24.0F, 0.0F); window_exterior_1.setTextureOffset(324, 343).addCuboid(20.0F, 0.0F, -16.0F, 1.0F, 7.0F, 32.0F, 0.0F, true); window_exterior_1.setTextureOffset(128, 46).addCuboid(20.0F, -14.0F, -18.0F, 0.0F, 14.0F, 36.0F, 0.0F, true); upper_wall_r2 = new ModelPart(this); upper_wall_r2.setPivot(20.0F, -14.0F, 0.0F); window_exterior_1.addChild(upper_wall_r2); setRotationAngle(upper_wall_r2, 0.0F, 0.0F, -0.1107F); upper_wall_r2.setTextureOffset(58, 112).addCuboid(0.0F, -19.0F, -18.0F, 0.0F, 19.0F, 36.0F, 0.0F, true); window_exterior_2 = new ModelPart(this); window_exterior_2.setPivot(0.0F, 24.0F, 0.0F); window_exterior_2.setTextureOffset(324, 343).addCuboid(-21.0F, 0.0F, -16.0F, 1.0F, 7.0F, 32.0F, 0.0F, false); window_exterior_2.setTextureOffset(128, 46).addCuboid(-20.0F, -14.0F, -18.0F, 0.0F, 14.0F, 36.0F, 0.0F, false); upper_wall_r3 = new ModelPart(this); upper_wall_r3.setPivot(-20.0F, -14.0F, 0.0F); window_exterior_2.addChild(upper_wall_r3); setRotationAngle(upper_wall_r3, 0.0F, 0.0F, 0.1107F); upper_wall_r3.setTextureOffset(58, 112).addCuboid(0.0F, -19.0F, -18.0F, 0.0F, 19.0F, 36.0F, 0.0F, false); side_panel_sp1900 = new ModelPart(this); side_panel_sp1900.setPivot(0.0F, 24.0F, 0.0F); side_panel_sp1900.setTextureOffset(38, 188).addCuboid(-18.0F, -34.0F, 0.0F, 7.0F, 30.0F, 0.0F, 0.0F, false); side_panel_sp1900.setTextureOffset(12, 18).addCuboid(-12.0F, -16.0F, 0.0F, 0.0F, 10.0F, 0.0F, 0.2F, false); side_panel_sp1900.setTextureOffset(12, 18).addCuboid(-10.3698F, -26.2455F, 0.0F, 0.0F, 3.0F, 0.0F, 0.2F, false); handrail_7_r1 = new ModelPart(this); handrail_7_r1.setPivot(-11.8689F, -31.7477F, 0.0F); side_panel_sp1900.addChild(handrail_7_r1); setRotationAngle(handrail_7_r1, 0.0F, 0.0F, -0.3491F); handrail_7_r1.setTextureOffset(12, 18).addCuboid(0.0F, -3.0F, 0.0F, 0.0F, 6.0F, 0.0F, 0.2F, false); handrail_6_r1 = new ModelPart(this); handrail_6_r1.setPivot(-10.5751F, -27.5926F, 0.0F); side_panel_sp1900.addChild(handrail_6_r1); setRotationAngle(handrail_6_r1, 0.0F, 0.0F, -0.1745F); handrail_6_r1.setTextureOffset(12, 18).addCuboid(0.0F, -1.0F, 0.0F, 0.0F, 2.0F, 0.0F, 0.2F, false); handrail_4_r1 = new ModelPart(this); handrail_4_r1.setPivot(-10.5751F, -21.8985F, 0.0F); side_panel_sp1900.addChild(handrail_4_r1); setRotationAngle(handrail_4_r1, 0.0F, 0.0F, 0.1745F); handrail_4_r1.setTextureOffset(12, 18).addCuboid(0.0F, -1.0F, 0.0F, 0.0F, 2.0F, 0.0F, 0.2F, false); handrail_3_r1 = new ModelPart(this); handrail_3_r1.setPivot(-11.1849F, -19.6228F, 0.0F); side_panel_sp1900.addChild(handrail_3_r1); setRotationAngle(handrail_3_r1, 0.0F, 0.0F, 0.3491F); handrail_3_r1.setTextureOffset(12, 18).addCuboid(0.0F, -1.0F, 0.0F, 0.0F, 2.0F, 0.0F, 0.2F, false); handrail_2_r1 = new ModelPart(this); handrail_2_r1.setPivot(-11.7947F, -17.347F, 0.0F); side_panel_sp1900.addChild(handrail_2_r1); setRotationAngle(handrail_2_r1, 0.0F, 0.0F, 0.1745F); handrail_2_r1.setTextureOffset(12, 18).addCuboid(0.0F, -1.0F, 0.0F, 0.0F, 2.0F, 0.0F, 0.2F, false); side_panel_c1141a = new ModelPart(this); side_panel_c1141a.setPivot(0.0F, 24.0F, 0.0F); side_panel_c1141a.setTextureOffset(38, 218).addCuboid(-18.0F, -29.0F, 0.0F, 7.0F, 24.0F, 0.0F, 0.0F, false); side_panel_c1141a.setTextureOffset(8, 4).addCuboid(-11.0F, -28.0F, 0.0F, 0.0F, 23.0F, 0.0F, 0.2F, false); side_panel_c1141a.setTextureOffset(224, 31).addCuboid(-18.7F, -12.5F, -0.5F, 8.0F, 4.0F, 1.0F, 0.0F, false); handrail_5_r1 = new ModelPart(this); handrail_5_r1.setPivot(-14.4899F, -28.9899F, 0.0F); side_panel_c1141a.addChild(handrail_5_r1); setRotationAngle(handrail_5_r1, 0.0F, 0.0F, 1.5708F); handrail_5_r1.setTextureOffset(8, 24).addCuboid(0.0F, -2.5F, 0.0F, 0.0F, 5.0F, 0.0F, 0.2F, false); handrail_3_r2 = new ModelPart(this); handrail_3_r2.setPivot(-10.0929F, -27.4929F, 0.2F); side_panel_c1141a.addChild(handrail_3_r2); setRotationAngle(handrail_3_r2, 0.0F, 0.0F, -0.7854F); handrail_3_r2.setTextureOffset(8, 24).addCuboid(-0.2F, -2.2F, -0.2F, 0.0F, 1.0F, 0.0F, 0.2F, false); door = new ModelPart(this); door.setPivot(0.0F, 24.0F, 0.0F); door.setTextureOffset(128, 49).addCuboid(-20.0F, 0.0F, -16.0F, 20.0F, 1.0F, 32.0F, 0.0F, false); door.setTextureOffset(128, 66).addCuboid(-5.0F, -36.0F, -5.0F, 5.0F, 1.0F, 10.0F, 0.0F, false); door_left = new ModelPart(this); door_left.setPivot(0.0F, 0.0F, 0.0F); door.addChild(door_left); door_left.setTextureOffset(224, 251).addCuboid(-20.8F, -14.0F, 0.0F, 1.0F, 14.0F, 16.0F, 0.0F, false); door_left_top_r1 = new ModelPart(this); door_left_top_r1.setPivot(-20.8F, -14.0F, 0.0F); door_left.addChild(door_left_top_r1); setRotationAngle(door_left_top_r1, 0.0F, 0.0F, 0.1107F); door_left_top_r1.setTextureOffset(236, 122).addCuboid(0.0F, -19.0F, 0.0F, 1.0F, 19.0F, 16.0F, 0.0F, false); door_right = new ModelPart(this); door_right.setPivot(0.0F, 0.0F, 0.0F); door.addChild(door_right); door_right.setTextureOffset(156, 251).addCuboid(-20.8F, -14.0F, -16.0F, 1.0F, 14.0F, 16.0F, 0.0F, false); door_right_top_r1 = new ModelPart(this); door_right_top_r1.setPivot(-20.8F, -14.0F, 0.0F); door_right.addChild(door_right_top_r1); setRotationAngle(door_right_top_r1, 0.0F, 0.0F, 0.1107F); door_right_top_r1.setTextureOffset(116, 251).addCuboid(0.0F, -19.0F, -16.0F, 1.0F, 19.0F, 16.0F, 0.0F, false); door_light_c1141a = new ModelPart(this); door_light_c1141a.setPivot(0.0F, 24.0F, 0.0F); door_light_c1141a.setTextureOffset(96, 40).addCuboid(-4.0F, -36.0F, -3.5F, 4.0F, 1.0F, 0.0F, 0.0F, false); door_light_c1141a.setTextureOffset(96, 32).addCuboid(-3.5F, -36.0F, -4.0F, 0.0F, 1.0F, 8.0F, 0.0F, false); door_light_c1141a.setTextureOffset(96, 40).addCuboid(-4.0F, -36.0F, 3.5F, 4.0F, 1.0F, 0.0F, 0.0F, false); door_exterior_1 = new ModelPart(this); door_exterior_1.setPivot(0.0F, 24.0F, 0.0F); door_exterior_1.setTextureOffset(178, 334).addCuboid(20.0F, 0.0F, -16.0F, 1.0F, 7.0F, 32.0F, 0.0F, true); door_right_exterior_1 = new ModelPart(this); door_right_exterior_1.setPivot(0.0F, 0.0F, 0.0F); door_exterior_1.addChild(door_right_exterior_1); door_right_exterior_1.setTextureOffset(128, 33).addCuboid(20.8F, -14.0F, 0.0F, 0.0F, 14.0F, 16.0F, 0.0F, true); door_left_top_r2 = new ModelPart(this); door_left_top_r2.setPivot(20.8F, -14.0F, 0.0F); door_right_exterior_1.addChild(door_left_top_r2); setRotationAngle(door_left_top_r2, 0.0F, 0.0F, -0.1107F); door_left_top_r2.setTextureOffset(130, 99).addCuboid(0.0F, -19.0F, 0.0F, 0.0F, 19.0F, 16.0F, 0.0F, true); door_left_exterior_1 = new ModelPart(this); door_left_exterior_1.setPivot(0.0F, 0.0F, 0.0F); door_exterior_1.addChild(door_left_exterior_1); door_left_exterior_1.setTextureOffset(96, 33).addCuboid(20.8F, -14.0F, -16.0F, 0.0F, 14.0F, 16.0F, 0.0F, true); door_right_top_r2_r1 = new ModelPart(this); door_right_top_r2_r1.setPivot(20.8F, -14.0F, 0.0F); door_left_exterior_1.addChild(door_right_top_r2_r1); setRotationAngle(door_right_top_r2_r1, 0.0F, 0.0F, -0.1107F); door_right_top_r2_r1.setTextureOffset(58, 99).addCuboid(0.0F, -19.0F, -16.0F, 0.0F, 19.0F, 16.0F, 0.0F, true); door_exterior_2 = new ModelPart(this); door_exterior_2.setPivot(0.0F, 24.0F, 0.0F); door_exterior_2.setTextureOffset(178, 334).addCuboid(-21.0F, 0.0F, -16.0F, 1.0F, 7.0F, 32.0F, 0.0F, false); door_left_exterior_2 = new ModelPart(this); door_left_exterior_2.setPivot(0.0F, 0.0F, 0.0F); door_exterior_2.addChild(door_left_exterior_2); door_left_exterior_2.setTextureOffset(128, 33).addCuboid(-20.8F, -14.0F, 0.0F, 0.0F, 14.0F, 16.0F, 0.0F, false); door_left_top_r3 = new ModelPart(this); door_left_top_r3.setPivot(-20.8F, -14.0F, 0.0F); door_left_exterior_2.addChild(door_left_top_r3); setRotationAngle(door_left_top_r3, 0.0F, 0.0F, 0.1107F); door_left_top_r3.setTextureOffset(130, 99).addCuboid(0.0F, -19.0F, 0.0F, 0.0F, 19.0F, 16.0F, 0.0F, false); door_right_exterior_2 = new ModelPart(this); door_right_exterior_2.setPivot(0.0F, 0.0F, 0.0F); door_exterior_2.addChild(door_right_exterior_2); door_right_exterior_2.setTextureOffset(96, 33).addCuboid(-20.8F, -14.0F, -16.0F, 0.0F, 14.0F, 16.0F, 0.0F, false); door_right_top_r3_r1 = new ModelPart(this); door_right_top_r3_r1.setPivot(-20.8F, -14.0F, 0.0F); door_right_exterior_2.addChild(door_right_top_r3_r1); setRotationAngle(door_right_top_r3_r1, 0.0F, 0.0F, 0.1107F); door_right_top_r3_r1.setTextureOffset(58, 99).addCuboid(0.0F, -19.0F, -16.0F, 0.0F, 19.0F, 16.0F, 0.0F, false); end = new ModelPart(this); end.setPivot(0.0F, 24.0F, 0.0F); end.setTextureOffset(96, 0).addCuboid(-20.0F, 0.0F, -32.0F, 40.0F, 1.0F, 48.0F, 0.0F, false); end.setTextureOffset(58, 251).addCuboid(18.0F, -14.0F, -36.0F, 2.0F, 14.0F, 54.0F, 0.0F, true); end.setTextureOffset(228, 124).addCuboid(-20.0F, -14.0F, -36.0F, 2.0F, 14.0F, 54.0F, 0.0F, false); end.setTextureOffset(0, 188).addCuboid(11.0F, -33.0F, -36.0F, 7.0F, 33.0F, 12.0F, 0.0F, false); end.setTextureOffset(0, 115).addCuboid(-18.0F, -33.0F, -36.0F, 7.0F, 33.0F, 12.0F, 0.0F, false); end.setTextureOffset(320, 320).addCuboid(-18.0F, -44.0F, -36.0F, 36.0F, 11.0F, 12.0F, 0.0F, false); upper_wall_2_r1 = new ModelPart(this); upper_wall_2_r1.setPivot(-20.0F, -14.0F, 0.0F); end.addChild(upper_wall_2_r1); setRotationAngle(upper_wall_2_r1, 0.0F, 0.0F, 0.1107F); upper_wall_2_r1.setTextureOffset(170, 178).addCuboid(0.0F, -19.0F, -36.0F, 2.0F, 19.0F, 54.0F, 0.0F, false); upper_wall_1_r1 = new ModelPart(this); upper_wall_1_r1.setPivot(20.0F, -14.0F, 0.0F); end.addChild(upper_wall_1_r1); setRotationAngle(upper_wall_1_r1, 0.0F, 0.0F, -0.1107F); upper_wall_1_r1.setTextureOffset(194, 49).addCuboid(-2.0F, -19.0F, -36.0F, 2.0F, 19.0F, 54.0F, 0.0F, true); seat_end_1 = new ModelPart(this); seat_end_1.setPivot(0.0F, 0.0F, 0.0F); end.addChild(seat_end_1); seat_end_1.setTextureOffset(116, 178).addCuboid(11.0F, -6.0F, -24.0F, 7.0F, 1.0F, 40.0F, 0.0F, false); seat_back_1_c1141a_r1 = new ModelPart(this); seat_back_1_c1141a_r1.setPivot(18.0F, -6.5F, 0.0F); seat_end_1.addChild(seat_back_1_c1141a_r1); setRotationAngle(seat_back_1_c1141a_r1, 0.0F, 0.0F, 0.0873F); seat_back_1_c1141a_r1.setTextureOffset(282, 343).addCuboid(-1.0F, -6.0F, -24.0F, 1.0F, 4.0F, 40.0F, 0.0F, false); seat_back_1_c1141a_r1.setTextureOffset(194, 122).addCuboid(-1.0F, -8.0F, -24.0F, 1.0F, 8.0F, 40.0F, 0.0F, false); seat_end_2 = new ModelPart(this); seat_end_2.setPivot(0.0F, 0.0F, 0.0F); end.addChild(seat_end_2); seat_back_2_c1141a_r1 = new ModelPart(this); seat_back_2_c1141a_r1.setPivot(-18.0F, -6.5F, 0.0F); seat_end_2.addChild(seat_back_2_c1141a_r1); setRotationAngle(seat_back_2_c1141a_r1, 0.0F, 3.1416F, -0.1047F); seat_back_2_c1141a_r1.setTextureOffset(282, 343).addCuboid(-1.0F, -6.0F, -16.0F, 1.0F, 4.0F, 40.0F, 0.0F, false); seat_back_2_c1141a_r1.setTextureOffset(194, 122).addCuboid(-1.0F, -8.0F, -16.0F, 1.0F, 8.0F, 40.0F, 0.0F, false); seat_bottom_2_r1 = new ModelPart(this); seat_bottom_2_r1.setPivot(0.0F, 0.0F, 0.0F); seat_end_2.addChild(seat_bottom_2_r1); setRotationAngle(seat_bottom_2_r1, 0.0F, 3.1416F, 0.0F); seat_bottom_2_r1.setTextureOffset(116, 178).addCuboid(11.0F, -6.0F, -16.0F, 7.0F, 1.0F, 40.0F, 0.0F, false); end_exterior = new ModelPart(this); end_exterior.setPivot(0.0F, 24.0F, 0.0F); end_exterior.setTextureOffset(0, 271).addCuboid(-21.0F, 0.0F, -32.0F, 1.0F, 7.0F, 48.0F, 0.0F, false); end_exterior.setTextureOffset(228, 228).addCuboid(18.0F, -14.0F, -36.0F, 2.0F, 14.0F, 54.0F, 0.0F, true); end_exterior.setTextureOffset(0, 197).addCuboid(-20.0F, -14.0F, -36.0F, 2.0F, 14.0F, 54.0F, 0.0F, false); end_exterior.setTextureOffset(162, 115).addCuboid(11.0F, -33.0F, -36.0F, 7.0F, 33.0F, 0.0F, 0.0F, false); end_exterior.setTextureOffset(38, 115).addCuboid(-18.0F, -33.0F, -36.0F, 7.0F, 33.0F, 0.0F, 0.0F, false); end_exterior.setTextureOffset(116, 219).addCuboid(-18.0F, -44.0F, -36.0F, 36.0F, 11.0F, 0.0F, 0.0F, false); outer_roof_2_r1 = new ModelPart(this); outer_roof_2_r1.setPivot(20.0F, -14.0F, 0.0F); end_exterior.addChild(outer_roof_2_r1); setRotationAngle(outer_roof_2_r1, 0.0F, 0.0F, -0.1107F); outer_roof_2_r1.setTextureOffset(170, 251).addCuboid(0.0F, -26.0F, -36.0F, 1.0F, 8.0F, 52.0F, 0.0F, true); outer_roof_2_r1.setTextureOffset(58, 178).addCuboid(-2.0F, -19.0F, -36.0F, 2.0F, 19.0F, 54.0F, 0.0F, true); outer_roof_1_r1 = new ModelPart(this); outer_roof_1_r1.setPivot(-20.0F, -14.0F, 0.0F); end_exterior.addChild(outer_roof_1_r1); setRotationAngle(outer_roof_1_r1, 0.0F, 0.0F, 0.1107F); outer_roof_1_r1.setTextureOffset(170, 251).addCuboid(-1.0F, -26.0F, -36.0F, 1.0F, 8.0F, 52.0F, 0.0F, false); outer_roof_1_r1.setTextureOffset(0, 115).addCuboid(0.0F, -19.0F, -36.0F, 2.0F, 19.0F, 54.0F, 0.0F, false); floor_1_r1 = new ModelPart(this); floor_1_r1.setPivot(0.0F, 0.0F, 0.0F); end_exterior.addChild(floor_1_r1); setRotationAngle(floor_1_r1, 0.0F, 3.1416F, 0.0F); floor_1_r1.setTextureOffset(0, 271).addCuboid(-21.0F, 0.0F, -16.0F, 1.0F, 7.0F, 48.0F, 0.0F, false); roof_sp1900 = new ModelPart(this); roof_sp1900.setPivot(0.0F, 24.0F, 0.0F); roof_sp1900.setTextureOffset(70, 0).addCuboid(-18.0F, -32.0F, -16.0F, 3.0F, 0.0F, 32.0F, 0.0F, false); roof_sp1900.setTextureOffset(8, 0).addCuboid(-4.0F, -36.0F, -16.0F, 4.0F, 0.0F, 32.0F, 0.0F, false); inner_roof_6_r1 = new ModelPart(this); inner_roof_6_r1.setPivot(-5.1552F, -35.6379F, 0.0F); roof_sp1900.addChild(inner_roof_6_r1); setRotationAngle(inner_roof_6_r1, 0.0F, 0.0F, -0.2618F); inner_roof_6_r1.setTextureOffset(64, 0).addCuboid(-1.5F, 0.0F, -16.0F, 3.0F, 0.0F, 32.0F, 0.0F, false); inner_roof_5_r1 = new ModelPart(this); inner_roof_5_r1.setPivot(-11.3018F, -34.9909F, 0.0F); roof_sp1900.addChild(inner_roof_5_r1); setRotationAngle(inner_roof_5_r1, 0.0F, 0.0F, -0.2618F); inner_roof_5_r1.setTextureOffset(8, 66).addCuboid(-1.0F, 0.0F, -16.0F, 2.0F, 0.0F, 32.0F, 0.0F, false); inner_roof_4_r1 = new ModelPart(this); inner_roof_4_r1.setPivot(-12.7005F, -34.4822F, 0.0F); roof_sp1900.addChild(inner_roof_4_r1); setRotationAngle(inner_roof_4_r1, 0.0F, 0.0F, -0.5236F); inner_roof_4_r1.setTextureOffset(78, 0).addCuboid(-0.5F, 0.0F, -16.0F, 1.0F, 0.0F, 32.0F, 0.0F, false); inner_roof_3_r1 = new ModelPart(this); inner_roof_3_r1.setPivot(-13.6331F, -33.3665F, 0.0F); roof_sp1900.addChild(inner_roof_3_r1); setRotationAngle(inner_roof_3_r1, 0.0F, 0.0F, -1.0472F); inner_roof_3_r1.setTextureOffset(12, 66).addCuboid(-1.0F, 0.0F, -16.0F, 2.0F, 0.0F, 32.0F, 0.0F, false); inner_roof_2_r1 = new ModelPart(this); inner_roof_2_r1.setPivot(-14.5665F, -32.2501F, 0.0F); roof_sp1900.addChild(inner_roof_2_r1); setRotationAngle(inner_roof_2_r1, 0.0F, 0.0F, -0.5236F); inner_roof_2_r1.setTextureOffset(80, 0).addCuboid(-0.5F, 0.0F, -16.0F, 1.0F, 0.0F, 32.0F, 0.0F, false); roof_c1141a = new ModelPart(this); roof_c1141a.setPivot(0.0F, 24.0F, 0.0F); roof_c1141a.setTextureOffset(70, 0).addCuboid(-18.0F, -32.0F, -16.0F, 3.0F, 0.0F, 32.0F, 0.0F, false); roof_c1141a.setTextureOffset(8, 376).addCuboid(-13.0F, -36.0F, -16.0F, 13.0F, 0.0F, 32.0F, 0.0F, false); inner_roof_3_r2 = new ModelPart(this); inner_roof_3_r2.setPivot(-15.0F, -32.0F, 16.0F); roof_c1141a.addChild(inner_roof_3_r2); setRotationAngle(inner_roof_3_r2, 0.0F, 0.0F, -1.0472F); inner_roof_3_r2.setTextureOffset(206, 49).addCuboid(0.0F, 0.0F, -32.0F, 5.0F, 0.0F, 32.0F, 0.0F, false); roof_exterior = new ModelPart(this); roof_exterior.setPivot(0.0F, 24.0F, 0.0F); roof_exterior.setTextureOffset(98, 0).addCuboid(-6.0F, -44.0F, -16.0F, 6.0F, 0.0F, 32.0F, 0.0F, false); outer_roof_4_r1 = new ModelPart(this); outer_roof_4_r1.setPivot(-9.9391F, -43.3054F, 0.0F); roof_exterior.addChild(outer_roof_4_r1); setRotationAngle(outer_roof_4_r1, 0.0F, 0.0F, -0.1745F); outer_roof_4_r1.setTextureOffset(82, 0).addCuboid(-4.0F, 0.0F, -16.0F, 8.0F, 0.0F, 32.0F, 0.0F, false); outer_roof_3_r1 = new ModelPart(this); outer_roof_3_r1.setPivot(-15.1773F, -41.8608F, 0.0F); roof_exterior.addChild(outer_roof_3_r1); setRotationAngle(outer_roof_3_r1, 0.0F, 0.0F, -0.5236F); outer_roof_3_r1.setTextureOffset(20, 0).addCuboid(-1.5F, 0.0F, -16.0F, 3.0F, 0.0F, 32.0F, 0.0F, false); outer_roof_2_r2 = new ModelPart(this); outer_roof_2_r2.setPivot(-16.9764F, -40.2448F, 0.0F); roof_exterior.addChild(outer_roof_2_r2); setRotationAngle(outer_roof_2_r2, 0.0F, 0.0F, -1.0472F); outer_roof_2_r2.setTextureOffset(26, 6).addCuboid(-1.0F, 0.0F, -16.0F, 2.0F, 0.0F, 32.0F, 0.0F, false); outer_roof_1_r2 = new ModelPart(this); outer_roof_1_r2.setPivot(-20.0F, -14.0F, 0.0F); roof_exterior.addChild(outer_roof_1_r2); setRotationAngle(outer_roof_1_r2, 0.0F, 0.0F, 0.1107F); outer_roof_1_r2.setTextureOffset(344, 228).addCuboid(-1.0F, -26.0F, -16.0F, 1.0F, 8.0F, 32.0F, 0.0F, false); roof_light_sp1900 = new ModelPart(this); roof_light_sp1900.setPivot(0.0F, 24.0F, 0.0F); roof_light_sp1900.setTextureOffset(16, 8).addCuboid(-9.4701F, -34.7497F, -16.0F, 2.0F, 0.0F, 32.0F, 0.0F, false); light_3_r1 = new ModelPart(this); light_3_r1.setPivot(-7.0366F, -34.9988F, 0.0F); roof_light_sp1900.addChild(light_3_r1); setRotationAngle(light_3_r1, 0.0F, 0.0F, -0.5236F); light_3_r1.setTextureOffset(30, 22).addCuboid(-0.5F, 0.0F, -16.0F, 1.0F, 0.0F, 32.0F, 0.0F, false); light_1_r1 = new ModelPart(this); light_1_r1.setPivot(-9.9036F, -34.9998F, 0.0F); roof_light_sp1900.addChild(light_1_r1); setRotationAngle(light_1_r1, 0.0F, 0.0F, 0.5236F); light_1_r1.setTextureOffset(76, 0).addCuboid(-0.5F, 0.0F, -16.0F, 1.0F, 0.0F, 32.0F, 0.0F, false); roof_light_c1141a = new ModelPart(this); roof_light_c1141a.setPivot(0.0F, 24.0F, 0.0F); roof_light_c1141a.setTextureOffset(274, 69).addCuboid(-10.0F, -36.1F, -16.0F, 4.0F, 0.0F, 32.0F, 0.0F, false); roof_end_sp1900 = new ModelPart(this); roof_end_sp1900.setPivot(0.0F, 24.0F, 0.0F); inner_roof_1 = new ModelPart(this); inner_roof_1.setPivot(0.0F, 0.0F, 0.0F); roof_end_sp1900.addChild(inner_roof_1); inner_roof_1.setTextureOffset(62, 0).addCuboid(-18.0F, -32.0F, -24.0F, 3.0F, 0.0F, 40.0F, 0.0F, false); inner_roof_1.setTextureOffset(0, 0).addCuboid(-4.0F, -36.0F, -24.0F, 4.0F, 0.0F, 40.0F, 0.0F, false); inner_roof_6_r2 = new ModelPart(this); inner_roof_6_r2.setPivot(-5.1551F, -35.6369F, -4.0F); inner_roof_1.addChild(inner_roof_6_r2); setRotationAngle(inner_roof_6_r2, 0.0F, 0.0F, -0.2618F); inner_roof_6_r2.setTextureOffset(56, 0).addCuboid(-1.5F, 0.0F, -20.0F, 3.0F, 0.0F, 40.0F, 0.0F, false); inner_roof_5_r2 = new ModelPart(this); inner_roof_5_r2.setPivot(-11.3023F, -34.9918F, -4.0F); inner_roof_1.addChild(inner_roof_5_r2); setRotationAngle(inner_roof_5_r2, 0.0F, 0.0F, -0.2618F); inner_roof_5_r2.setTextureOffset(0, 66).addCuboid(-1.0F, 0.0F, -20.0F, 2.0F, 0.0F, 40.0F, 0.0F, false); inner_roof_4_r2 = new ModelPart(this); inner_roof_4_r2.setPivot(-12.701F, -34.4831F, -4.0F); inner_roof_1.addChild(inner_roof_4_r2); setRotationAngle(inner_roof_4_r2, 0.0F, 0.0F, -0.5236F); inner_roof_4_r2.setTextureOffset(70, 0).addCuboid(-0.5F, 0.0F, -20.0F, 1.0F, 0.0F, 40.0F, 0.0F, false); inner_roof_3_r3 = new ModelPart(this); inner_roof_3_r3.setPivot(-13.6331F, -33.3665F, -4.0F); inner_roof_1.addChild(inner_roof_3_r3); setRotationAngle(inner_roof_3_r3, 0.0F, 0.0F, -1.0472F); inner_roof_3_r3.setTextureOffset(4, 66).addCuboid(-1.0F, 0.0F, -20.0F, 2.0F, 0.0F, 40.0F, 0.0F, false); inner_roof_2_r2 = new ModelPart(this); inner_roof_2_r2.setPivot(-14.5665F, -32.2501F, -4.0F); inner_roof_1.addChild(inner_roof_2_r2); setRotationAngle(inner_roof_2_r2, 0.0F, 0.0F, -0.5236F); inner_roof_2_r2.setTextureOffset(72, 0).addCuboid(-0.5F, 0.0F, -20.0F, 1.0F, 0.0F, 40.0F, 0.0F, false); inner_roof_2 = new ModelPart(this); inner_roof_2.setPivot(0.0F, 0.0F, 0.0F); roof_end_sp1900.addChild(inner_roof_2); inner_roof_2.setTextureOffset(62, 0).addCuboid(15.0F, -32.0F, -24.0F, 3.0F, 0.0F, 40.0F, 0.0F, true); inner_roof_2.setTextureOffset(0, 0).addCuboid(0.0F, -36.0F, -24.0F, 4.0F, 0.0F, 40.0F, 0.0F, true); inner_roof_6_r3 = new ModelPart(this); inner_roof_6_r3.setPivot(5.1554F, -35.6388F, -4.0F); inner_roof_2.addChild(inner_roof_6_r3); setRotationAngle(inner_roof_6_r3, 0.0F, 0.0F, 0.2618F); inner_roof_6_r3.setTextureOffset(56, 0).addCuboid(-1.5F, 0.0F, -20.0F, 3.0F, 0.0F, 40.0F, 0.0F, true); inner_roof_5_r3 = new ModelPart(this); inner_roof_5_r3.setPivot(11.3023F, -34.9908F, -4.0F); inner_roof_2.addChild(inner_roof_5_r3); setRotationAngle(inner_roof_5_r3, 0.0F, 0.0F, 0.2618F); inner_roof_5_r3.setTextureOffset(0, 66).addCuboid(-1.0F, 0.0F, -20.0F, 2.0F, 0.0F, 40.0F, 0.0F, true); inner_roof_4_r3 = new ModelPart(this); inner_roof_4_r3.setPivot(12.701F, -34.4821F, -4.0F); inner_roof_2.addChild(inner_roof_4_r3); setRotationAngle(inner_roof_4_r3, 0.0F, 0.0F, 0.5236F); inner_roof_4_r3.setTextureOffset(72, 0).addCuboid(-0.5F, 0.0F, -20.0F, 1.0F, 0.0F, 40.0F, 0.0F, true); inner_roof_3_r4 = new ModelPart(this); inner_roof_3_r4.setPivot(13.6336F, -33.3664F, -4.0F); inner_roof_2.addChild(inner_roof_3_r4); setRotationAngle(inner_roof_3_r4, 0.0F, 0.0F, 1.0472F); inner_roof_3_r4.setTextureOffset(4, 66).addCuboid(-1.0F, 0.0F, -20.0F, 2.0F, 0.0F, 40.0F, 0.0F, true); inner_roof_2_r3 = new ModelPart(this); inner_roof_2_r3.setPivot(14.5665F, -32.2491F, -4.0F); inner_roof_2.addChild(inner_roof_2_r3); setRotationAngle(inner_roof_2_r3, 0.0F, 0.0F, 0.5236F); inner_roof_2_r3.setTextureOffset(72, 0).addCuboid(-0.5F, 0.0F, -20.0F, 1.0F, 0.0F, 40.0F, 0.0F, true); roof_end_c1141a = new ModelPart(this); roof_end_c1141a.setPivot(0.0F, 24.0F, 0.0F); inner_roof_3 = new ModelPart(this); inner_roof_3.setPivot(0.0F, 0.0F, 0.0F); roof_end_c1141a.addChild(inner_roof_3); inner_roof_3.setTextureOffset(62, 0).addCuboid(-18.0F, -32.0F, -24.0F, 3.0F, 0.0F, 40.0F, 0.0F, false); inner_roof_3.setTextureOffset(0, 376).addCuboid(-13.0F, -36.0F, -24.0F, 13.0F, 0.0F, 40.0F, 0.0F, false); inner_roof_3_r5 = new ModelPart(this); inner_roof_3_r5.setPivot(-15.0F, -32.0F, 0.0F); inner_roof_3.addChild(inner_roof_3_r5); setRotationAngle(inner_roof_3_r5, 0.0F, 0.0F, -1.0472F); inner_roof_3_r5.setTextureOffset(198, 49).addCuboid(0.0F, 0.0F, -24.0F, 5.0F, 0.0F, 40.0F, 0.0F, false); inner_roof_4 = new ModelPart(this); inner_roof_4.setPivot(0.0F, 0.0F, 0.0F); roof_end_c1141a.addChild(inner_roof_4); inner_roof_4.setTextureOffset(62, 0).addCuboid(15.0F, -32.0F, -24.0F, 3.0F, 0.0F, 40.0F, 0.0F, true); inner_roof_4.setTextureOffset(0, 376).addCuboid(0.0F, -36.0F, -24.0F, 13.0F, 0.0F, 40.0F, 0.0F, true); inner_roof_3_r6 = new ModelPart(this); inner_roof_3_r6.setPivot(15.0F, -32.0F, 0.0F); inner_roof_4.addChild(inner_roof_3_r6); setRotationAngle(inner_roof_3_r6, 0.0F, 0.0F, 1.0472F); inner_roof_3_r6.setTextureOffset(198, 49).addCuboid(-5.0F, 0.0F, -24.0F, 5.0F, 0.0F, 40.0F, 0.0F, true); roof_end_exterior = new ModelPart(this); roof_end_exterior.setPivot(0.0F, 24.0F, 0.0F); roof_end_exterior.setTextureOffset(0, 0).addCuboid(-8.0F, -45.0F, -36.0F, 16.0F, 2.0F, 64.0F, 0.0F, false); vent_2_r1 = new ModelPart(this); vent_2_r1.setPivot(-8.0F, -45.0F, 0.0F); roof_end_exterior.addChild(vent_2_r1); setRotationAngle(vent_2_r1, 0.0F, 0.0F, -0.3491F); vent_2_r1.setTextureOffset(112, 112).addCuboid(-9.0F, 0.0F, -36.0F, 9.0F, 2.0F, 64.0F, 0.0F, true); vent_1_r1 = new ModelPart(this); vent_1_r1.setPivot(8.0F, -45.0F, 0.0F); roof_end_exterior.addChild(vent_1_r1); setRotationAngle(vent_1_r1, 0.0F, 0.0F, 0.3491F); vent_1_r1.setTextureOffset(112, 112).addCuboid(0.0F, 0.0F, -36.0F, 9.0F, 2.0F, 64.0F, 0.0F, false); outer_roof_1 = new ModelPart(this); outer_roof_1.setPivot(0.0F, 0.0F, 0.0F); roof_end_exterior.addChild(outer_roof_1); outer_roof_3_r2 = new ModelPart(this); outer_roof_3_r2.setPivot(-15.1773F, -41.8608F, -10.0F); outer_roof_1.addChild(outer_roof_3_r2); setRotationAngle(outer_roof_3_r2, 0.0F, 0.0F, -0.5236F); outer_roof_3_r2.setTextureOffset(0, 0).addCuboid(-1.5F, 0.0F, -26.0F, 3.0F, 0.0F, 52.0F, 0.0F, false); outer_roof_2_r3 = new ModelPart(this); outer_roof_2_r3.setPivot(-16.9764F, -40.2448F, -10.0F); outer_roof_1.addChild(outer_roof_2_r3); setRotationAngle(outer_roof_2_r3, 0.0F, 0.0F, -1.0472F); outer_roof_2_r3.setTextureOffset(6, 6).addCuboid(-1.0F, 0.0F, -26.0F, 2.0F, 0.0F, 52.0F, 0.0F, false); outer_roof_2 = new ModelPart(this); outer_roof_2.setPivot(0.0F, 0.0F, 0.0F); roof_end_exterior.addChild(outer_roof_2); outer_roof_3_r3 = new ModelPart(this); outer_roof_3_r3.setPivot(15.1773F, -41.8608F, -10.0F); outer_roof_2.addChild(outer_roof_3_r3); setRotationAngle(outer_roof_3_r3, 0.0F, 0.0F, 0.5236F); outer_roof_3_r3.setTextureOffset(0, 0).addCuboid(-1.5F, 0.0F, -26.0F, 3.0F, 0.0F, 52.0F, 0.0F, true); outer_roof_2_r4 = new ModelPart(this); outer_roof_2_r4.setPivot(16.9764F, -40.2448F, -10.0F); outer_roof_2.addChild(outer_roof_2_r4); setRotationAngle(outer_roof_2_r4, 0.0F, 0.0F, 1.0472F); outer_roof_2_r4.setTextureOffset(6, 6).addCuboid(-1.0F, 0.0F, -26.0F, 2.0F, 0.0F, 52.0F, 0.0F, true); roof_end_light_sp1900 = new ModelPart(this); roof_end_light_sp1900.setPivot(0.0F, 24.0F, 0.0F); roof_end_light_sp1900.setTextureOffset(8, 8).addCuboid(-9.4703F, -34.7496F, -24.0F, 2.0F, 0.0F, 40.0F, 0.0F, false); roof_end_light_sp1900.setTextureOffset(8, 8).addCuboid(7.4706F, -34.7506F, -24.0F, 2.0F, 0.0F, 40.0F, 0.0F, true); light_6_r1 = new ModelPart(this); light_6_r1.setPivot(7.0371F, -35.0007F, -4.0F); roof_end_light_sp1900.addChild(light_6_r1); setRotationAngle(light_6_r1, 0.0F, 0.0F, 0.5236F); light_6_r1.setTextureOffset(22, 22).addCuboid(-0.5F, 0.0F, -20.0F, 1.0F, 0.0F, 40.0F, 0.0F, true); light_4_r1 = new ModelPart(this); light_4_r1.setPivot(9.9041F, -34.9997F, -4.0F); roof_end_light_sp1900.addChild(light_4_r1); setRotationAngle(light_4_r1, 0.0F, 0.0F, -0.5236F); light_4_r1.setTextureOffset(68, 0).addCuboid(-0.5F, 0.0F, -20.0F, 1.0F, 0.0F, 40.0F, 0.0F, true); light_3_r2 = new ModelPart(this); light_3_r2.setPivot(-7.0368F, -34.9987F, -4.0F); roof_end_light_sp1900.addChild(light_3_r2); setRotationAngle(light_3_r2, 0.0F, 0.0F, -0.5236F); light_3_r2.setTextureOffset(22, 22).addCuboid(-0.5F, 0.0F, -20.0F, 1.0F, 0.0F, 40.0F, 0.0F, false); light_1_r2 = new ModelPart(this); light_1_r2.setPivot(-9.9038F, -34.9997F, -4.0F); roof_end_light_sp1900.addChild(light_1_r2); setRotationAngle(light_1_r2, 0.0F, 0.0F, 0.5236F); light_1_r2.setTextureOffset(68, 0).addCuboid(-0.5F, 0.0F, -20.0F, 1.0F, 0.0F, 40.0F, 0.0F, false); roof_end_light_c1141a = new ModelPart(this); roof_end_light_c1141a.setPivot(0.0F, 24.0F, 0.0F); roof_end_light_c1141a.setTextureOffset(266, 69).addCuboid(-10.0F, -36.1F, -24.0F, 4.0F, 0.0F, 40.0F, 0.0F, false); roof_end_light_c1141a.setTextureOffset(266, 69).addCuboid(6.0F, -36.1F, -24.0F, 4.0F, 0.0F, 40.0F, 0.0F, false); top_handrail_sp1900 = new ModelPart(this); top_handrail_sp1900.setPivot(0.0F, 24.0F, 0.0F); top_handrail_sp1900.setTextureOffset(0, 0).addCuboid(-5.0F, -36.0F, 15.8F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_sp1900.setTextureOffset(0, 0).addCuboid(-5.0F, -36.0F, -15.8F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_bottom_right_r1 = new ModelPart(this); top_handrail_bottom_right_r1.setPivot(-5.0F, -31.0876F, -6.8876F); top_handrail_sp1900.addChild(top_handrail_bottom_right_r1); setRotationAngle(top_handrail_bottom_right_r1, -1.5708F, 0.0F, 0.0F); top_handrail_bottom_right_r1.setTextureOffset(0, 0).addCuboid(0.0F, -7.0F, 0.0F, 0.0F, 14.0F, 0.0F, 0.2F, false); top_handrail_bottom_left_r1 = new ModelPart(this); top_handrail_bottom_left_r1.setPivot(-5.0F, -31.0876F, 6.8876F); top_handrail_sp1900.addChild(top_handrail_bottom_left_r1); setRotationAngle(top_handrail_bottom_left_r1, -1.5708F, 0.0F, 0.0F); top_handrail_bottom_left_r1.setTextureOffset(0, 0).addCuboid(0.0F, -7.0F, 0.0F, 0.0F, 14.0F, 0.0F, 0.2F, false); top_handrail_right_3_r1 = new ModelPart(this); top_handrail_right_3_r1.setPivot(-5.0F, -31.4108F, -14.5938F); top_handrail_sp1900.addChild(top_handrail_right_3_r1); setRotationAngle(top_handrail_right_3_r1, 1.0472F, 0.0F, 0.0F); top_handrail_right_3_r1.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, false); top_handrail_right_2_r1 = new ModelPart(this); top_handrail_right_2_r1.setPivot(-5.0F, -32.2938F, -15.4768F); top_handrail_sp1900.addChild(top_handrail_right_2_r1); setRotationAngle(top_handrail_right_2_r1, 0.5236F, 0.0F, 0.0F); top_handrail_right_2_r1.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, false); top_handrail_left_3_r1 = new ModelPart(this); top_handrail_left_3_r1.setPivot(-5.0F, -31.4108F, 14.5938F); top_handrail_sp1900.addChild(top_handrail_left_3_r1); setRotationAngle(top_handrail_left_3_r1, -1.0472F, 0.0F, 0.0F); top_handrail_left_3_r1.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, false); top_handrail_left_2_r1 = new ModelPart(this); top_handrail_left_2_r1.setPivot(-5.0F, -32.2938F, 15.4768F); top_handrail_sp1900.addChild(top_handrail_left_2_r1); setRotationAngle(top_handrail_left_2_r1, -0.5236F, 0.0F, 0.0F); top_handrail_left_2_r1.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, false); handrail_strap_1 = new ModelPart(this); handrail_strap_1.setPivot(0.0F, 0.0F, 0.0F); top_handrail_sp1900.addChild(handrail_strap_1); handrail_strap_1.setTextureOffset(12, 12).addCuboid(-6.0F, -32.0F, -12.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_1.setTextureOffset(12, 12).addCuboid(-6.0F, -32.0F, -6.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_1.setTextureOffset(12, 12).addCuboid(-6.0F, -32.0F, 0.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_1.setTextureOffset(12, 12).addCuboid(-6.0F, -32.0F, 6.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_1.setTextureOffset(12, 12).addCuboid(-6.0F, -32.0F, 12.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); top_handrail_c1141a = new ModelPart(this); top_handrail_c1141a.setPivot(0.0F, 24.0F, 0.0F); top_handrail_c1141a.setTextureOffset(0, 50).addCuboid(-5.0F, -31.0F, 15.8F, 5.0F, 0.0F, 0.0F, 0.2F, false); top_handrail_c1141a.setTextureOffset(0, 50).addCuboid(-5.0F, -31.0F, -15.8F, 5.0F, 0.0F, 0.0F, 0.2F, false); top_handrail_c1141a.setTextureOffset(0, 0).addCuboid(-4.727F, -36.6045F, -11.0F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_c1141a.setTextureOffset(0, 0).addCuboid(-4.727F, -36.6045F, 0.0F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_c1141a.setTextureOffset(0, 0).addCuboid(-4.727F, -36.6045F, 11.0F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_c1141a.setTextureOffset(0, 0).addCuboid(0.0F, -36.6046F, 13.6145F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_c1141a.setTextureOffset(0, 0).addCuboid(0.0F, -36.0F, 11.0F, 0.0F, 7.0F, 0.0F, 0.2F, false); top_handrail_c1141a.setTextureOffset(8, 7).addCuboid(0.0F, -23.2645F, 10.437F, 0.0F, 6.0F, 0.0F, 0.2F, false); top_handrail_c1141a.setTextureOffset(8, 7).addCuboid(0.0F, -23.2645F, 11.563F, 0.0F, 6.0F, 0.0F, 0.2F, false); top_handrail_c1141a.setTextureOffset(0, 0).addCuboid(0.0F, -12.0F, 11.0F, 0.0F, 12.0F, 0.0F, 0.2F, false); pole_bottom_diagonal_2_r1 = new ModelPart(this); pole_bottom_diagonal_2_r1.setPivot(0.0F, -14.4002F, 11.2819F); top_handrail_c1141a.addChild(pole_bottom_diagonal_2_r1); setRotationAngle(pole_bottom_diagonal_2_r1, -0.1047F, 0.0F, 0.0F); pole_bottom_diagonal_2_r1.setTextureOffset(11, 28).addCuboid(0.0F, -2.5F, 0.0F, 0.0F, 5.0F, 0.0F, 0.2F, false); pole_bottom_diagonal_1_r1 = new ModelPart(this); pole_bottom_diagonal_1_r1.setPivot(0.0F, -14.4002F, 10.7181F); top_handrail_c1141a.addChild(pole_bottom_diagonal_1_r1); setRotationAngle(pole_bottom_diagonal_1_r1, 0.1047F, 0.0F, 0.0F); pole_bottom_diagonal_1_r1.setTextureOffset(11, 28).addCuboid(0.0F, -2.5F, 0.0F, 0.0F, 5.0F, 0.0F, 0.2F, false); pole_top_diagonal_2_r1 = new ModelPart(this); pole_top_diagonal_2_r1.setPivot(0.2F, -28.8F, 10.8F); top_handrail_c1141a.addChild(pole_top_diagonal_2_r1); setRotationAngle(pole_top_diagonal_2_r1, 0.1047F, 0.0F, 0.0F); pole_top_diagonal_2_r1.setTextureOffset(11, 11).addCuboid(-0.2F, 0.2069F, 0.2F, 0.0F, 5.0F, 0.0F, 0.2F, false); pole_top_diagonal_1_r1 = new ModelPart(this); pole_top_diagonal_1_r1.setPivot(0.2F, -28.8F, 11.2F); top_handrail_c1141a.addChild(pole_top_diagonal_1_r1); setRotationAngle(pole_top_diagonal_1_r1, -0.1047F, 0.0F, 0.0F); pole_top_diagonal_1_r1.setTextureOffset(11, 11).addCuboid(-0.2F, 0.2069F, -0.2F, 0.0F, 5.0F, 0.0F, 0.2F, false); top_handrail_connector_bottom_4_r1 = new ModelPart(this); top_handrail_connector_bottom_4_r1.setPivot(0.0F, -32.2308F, 14.6605F); top_handrail_c1141a.addChild(top_handrail_connector_bottom_4_r1); setRotationAngle(top_handrail_connector_bottom_4_r1, 0.6981F, 0.0F, 0.0F); top_handrail_connector_bottom_4_r1.setTextureOffset(0, 0).addCuboid(0.0F, -1.5F, 0.0F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_connector_bottom_3_r1 = new ModelPart(this); top_handrail_connector_bottom_3_r1.setPivot(-5.7729F, -32.2308F, 0.0F); top_handrail_c1141a.addChild(top_handrail_connector_bottom_3_r1); setRotationAngle(top_handrail_connector_bottom_3_r1, 0.0F, 0.0F, 0.6981F); top_handrail_connector_bottom_3_r1.setTextureOffset(0, 0).addCuboid(0.0F, -1.5F, 11.0F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_connector_bottom_3_r1.setTextureOffset(0, 0).addCuboid(0.0F, -1.5F, 0.0F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_connector_bottom_3_r1.setTextureOffset(0, 0).addCuboid(0.0F, -1.5F, -11.0F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_bottom_right_r2 = new ModelPart(this); top_handrail_bottom_right_r2.setPivot(-6.9124F, -31.0F, -6.8876F); top_handrail_c1141a.addChild(top_handrail_bottom_right_r2); setRotationAngle(top_handrail_bottom_right_r2, 1.5708F, 0.0F, 0.0F); top_handrail_bottom_right_r2.setTextureOffset(0, 0).addCuboid(0.0F, -7.0F, 0.0F, 0.0F, 14.0F, 0.0F, 0.2F, false); top_handrail_bottom_left_r2 = new ModelPart(this); top_handrail_bottom_left_r2.setPivot(-6.9124F, -31.0F, 6.8876F); top_handrail_c1141a.addChild(top_handrail_bottom_left_r2); setRotationAngle(top_handrail_bottom_left_r2, -1.5708F, 0.0F, 0.0F); top_handrail_bottom_left_r2.setTextureOffset(0, 0).addCuboid(0.0F, -7.0F, 0.0F, 0.0F, 14.0F, 0.0F, 0.2F, false); top_handrail_right_4_r1 = new ModelPart(this); top_handrail_right_4_r1.setPivot(-6.5892F, -31.0F, -14.5938F); top_handrail_c1141a.addChild(top_handrail_right_4_r1); setRotationAngle(top_handrail_right_4_r1, 1.5708F, -0.5236F, 0.0F); top_handrail_right_4_r1.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, false); top_handrail_right_3_r2 = new ModelPart(this); top_handrail_right_3_r2.setPivot(-5.7062F, -31.0F, -15.4768F); top_handrail_c1141a.addChild(top_handrail_right_3_r2); setRotationAngle(top_handrail_right_3_r2, 1.5708F, -1.0472F, 0.0F); top_handrail_right_3_r2.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, false); top_handrail_left_4_r1 = new ModelPart(this); top_handrail_left_4_r1.setPivot(-6.5892F, -31.0F, 14.5938F); top_handrail_c1141a.addChild(top_handrail_left_4_r1); setRotationAngle(top_handrail_left_4_r1, -1.5708F, 0.5236F, 0.0F); top_handrail_left_4_r1.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, false); top_handrail_left_3_r2 = new ModelPart(this); top_handrail_left_3_r2.setPivot(-5.7062F, -31.0F, 15.4768F); top_handrail_c1141a.addChild(top_handrail_left_3_r2); setRotationAngle(top_handrail_left_3_r2, -1.5708F, 1.0472F, 0.0F); top_handrail_left_3_r2.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, false); handrail_strap_2 = new ModelPart(this); handrail_strap_2.setPivot(0.0F, 0.0F, 0.0F); top_handrail_c1141a.addChild(handrail_strap_2); handrail_strap_2.setTextureOffset(12, 12).addCuboid(-8.0F, -32.0F, -14.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_2.setTextureOffset(12, 12).addCuboid(-8.0F, -32.0F, -9.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_2.setTextureOffset(12, 12).addCuboid(-8.0F, -32.0F, -4.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_2.setTextureOffset(12, 12).addCuboid(-8.0F, -32.0F, 4.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_2.setTextureOffset(12, 12).addCuboid(-8.0F, -32.0F, 9.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_2.setTextureOffset(12, 12).addCuboid(-8.0F, -32.0F, 14.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_8_r1 = new ModelPart(this); handrail_strap_8_r1.setPivot(0.0F, 0.0F, 0.0F); handrail_strap_2.addChild(handrail_strap_8_r1); setRotationAngle(handrail_strap_8_r1, 0.0F, -1.5708F, 0.0F); handrail_strap_8_r1.setTextureOffset(12, 12).addCuboid(-16.8F, -32.0F, 3.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_8_r1.setTextureOffset(12, 12).addCuboid(14.8F, -32.0F, 3.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); tv_pole = new ModelPart(this); tv_pole.setPivot(0.0F, 24.0F, 0.0F); tv_pole.setTextureOffset(18, 0).addCuboid(-4.0F, -36.0F, -1.0F, 8.0F, 6.0F, 2.0F, 0.0F, false); tv_pole.setTextureOffset(4, 0).addCuboid(0.0F, -27.5F, 0.0F, 0.0F, 28.0F, 0.0F, 0.2F, false); tv_pole.setTextureOffset(4, 0).addCuboid(-1.0F, -27.5F, 0.0F, 2.0F, 0.0F, 0.0F, 0.2F, false); tv_right_r1 = new ModelPart(this); tv_right_r1.setPivot(4.0F, -30.0F, -1.0F); tv_pole.addChild(tv_right_r1); setRotationAngle(tv_right_r1, -0.1047F, 3.1416F, 0.0F); tv_right_r1.setTextureOffset(18, 8).addCuboid(0.0F, -7.0F, -1.0F, 8.0F, 7.0F, 1.0F, 0.0F, false); tv_left_r1 = new ModelPart(this); tv_left_r1.setPivot(4.0F, -30.0F, 1.0F); tv_pole.addChild(tv_left_r1); setRotationAngle(tv_left_r1, -0.1047F, 0.0F, 0.0F); tv_left_r1.setTextureOffset(18, 8).addCuboid(-8.0F, -7.0F, -1.0F, 8.0F, 7.0F, 1.0F, 0.0F, false); pole_5_r1 = new ModelPart(this); pole_5_r1.setPivot(-3.3885F, -29.8726F, 0.0F); tv_pole.addChild(pole_5_r1); setRotationAngle(pole_5_r1, 0.0F, 0.0F, 1.2217F); pole_5_r1.setTextureOffset(4, 0).addCuboid(-1.0F, 0.0F, 0.0F, 2.0F, 0.0F, 0.0F, 0.2F, false); pole_4_r1 = new ModelPart(this); pole_4_r1.setPivot(-1.2F, -27.3F, 0.0F); tv_pole.addChild(pole_4_r1); setRotationAngle(pole_4_r1, 0.0F, 0.0F, 0.6109F); pole_4_r1.setTextureOffset(4, 0).addCuboid(-2.2F, -0.2F, 0.0F, 2.0F, 0.0F, 0.0F, 0.2F, false); pole_2_r1 = new ModelPart(this); pole_2_r1.setPivot(1.2F, -27.3F, 0.0F); tv_pole.addChild(pole_2_r1); setRotationAngle(pole_2_r1, 0.0F, 0.0F, -0.6109F); pole_2_r1.setTextureOffset(4, 0).addCuboid(0.2F, -0.2F, 0.0F, 2.0F, 0.0F, 0.0F, 0.2F, false); pole_1_r1 = new ModelPart(this); pole_1_r1.setPivot(3.3885F, -29.8726F, 0.0F); tv_pole.addChild(pole_1_r1); setRotationAngle(pole_1_r1, 0.0F, 0.0F, -1.2217F); pole_1_r1.setTextureOffset(4, 0).addCuboid(-1.0F, 0.0F, 0.0F, 2.0F, 0.0F, 0.0F, 0.2F, false); head = new ModelPart(this); head.setPivot(0.0F, 24.0F, 0.0F); head.setTextureOffset(0, 66).addCuboid(-20.0F, 0.0F, -16.0F, 40.0F, 1.0F, 48.0F, 0.0F, false); head.setTextureOffset(326, 69).addCuboid(-20.0F, -14.0F, -18.0F, 2.0F, 14.0F, 36.0F, 0.0F, false); head.setTextureOffset(0, 326).addCuboid(18.0F, -14.0F, -18.0F, 2.0F, 14.0F, 36.0F, 0.0F, true); head.setTextureOffset(326, 192).addCuboid(-18.0F, -36.0F, 8.0F, 36.0F, 36.0F, 0.0F, 0.0F, false); upper_wall_2_r2 = new ModelPart(this); upper_wall_2_r2.setPivot(20.0F, -14.0F, 0.0F); head.addChild(upper_wall_2_r2); setRotationAngle(upper_wall_2_r2, 0.0F, 0.0F, -0.1107F); upper_wall_2_r2.setTextureOffset(240, 296).addCuboid(-2.0F, -19.0F, -18.0F, 2.0F, 19.0F, 36.0F, 0.0F, true); upper_wall_1_r2 = new ModelPart(this); upper_wall_1_r2.setPivot(-20.0F, -14.0F, 0.0F); head.addChild(upper_wall_1_r2); setRotationAngle(upper_wall_1_r2, 0.0F, 0.0F, 0.1107F); upper_wall_1_r2.setTextureOffset(304, 260).addCuboid(0.0F, -19.0F, -18.0F, 2.0F, 19.0F, 36.0F, 0.0F, false); seat_head_1 = new ModelPart(this); seat_head_1.setPivot(0.0F, 0.0F, 0.0F); head.addChild(seat_head_1); seat_head_1.setTextureOffset(0, 34).addCuboid(11.0F, -6.0F, -16.0F, 7.0F, 1.0F, 24.0F, 0.0F, false); seat_back_c1141a_r2 = new ModelPart(this); seat_back_c1141a_r2.setPivot(18.0F, -6.5F, 0.0F); seat_head_1.addChild(seat_back_c1141a_r2); setRotationAngle(seat_back_c1141a_r2, 0.0F, 0.0F, 0.0873F); seat_back_c1141a_r2.setTextureOffset(254, 71).addCuboid(-1.0F, -6.0F, -16.0F, 1.0F, 4.0F, 24.0F, 0.0F, false); seat_back_c1141a_r2.setTextureOffset(170, 178).addCuboid(-1.0F, -8.0F, -16.0F, 1.0F, 8.0F, 24.0F, 0.0F, false); seat_head_2 = new ModelPart(this); seat_head_2.setPivot(0.0F, 0.0F, 0.0F); head.addChild(seat_head_2); seat_back_c1141a_r3 = new ModelPart(this); seat_back_c1141a_r3.setPivot(-18.0F, -6.5F, 0.0F); seat_head_2.addChild(seat_back_c1141a_r3); setRotationAngle(seat_back_c1141a_r3, 0.0F, 3.1416F, -0.1047F); seat_back_c1141a_r3.setTextureOffset(254, 71).addCuboid(-1.0F, -6.0F, -8.0F, 1.0F, 4.0F, 24.0F, 0.0F, false); seat_back_c1141a_r3.setTextureOffset(170, 178).addCuboid(-1.0F, -8.0F, -8.0F, 1.0F, 8.0F, 24.0F, 0.0F, false); seat_bottom_r1 = new ModelPart(this); seat_bottom_r1.setPivot(0.0F, 0.0F, 0.0F); seat_head_2.addChild(seat_bottom_r1); setRotationAngle(seat_bottom_r1, 0.0F, 3.1416F, 0.0F); seat_bottom_r1.setTextureOffset(0, 34).addCuboid(11.0F, -6.0F, -8.0F, 7.0F, 1.0F, 24.0F, 0.0F, false); head_exterior = new ModelPart(this); head_exterior.setPivot(0.0F, 24.0F, 0.0F); head_exterior.setTextureOffset(224, 0).addCuboid(-21.0F, 0.0F, 8.0F, 42.0F, 7.0F, 24.0F, 0.0F, false); head_exterior.setTextureOffset(58, 188).addCuboid(-21.0F, 0.0F, -16.0F, 1.0F, 7.0F, 24.0F, 0.0F, false); head_exterior.setTextureOffset(40, 326).addCuboid(-18.0F, -36.0F, 9.0F, 36.0F, 36.0F, 0.0F, 0.0F, false); head_exterior.setTextureOffset(116, 251).addCuboid(-20.0F, -14.0F, -18.0F, 2.0F, 14.0F, 36.0F, 0.0F, false); head_exterior.setTextureOffset(116, 251).addCuboid(18.0F, -14.0F, -18.0F, 2.0F, 14.0F, 36.0F, 0.0F, true); head_exterior.setTextureOffset(200, 49).addCuboid(-20.8F, -14.0F, 16.0F, 1.0F, 14.0F, 16.0F, 0.0F, false); head_exterior.setTextureOffset(350, 22).addCuboid(19.8F, -14.0F, 16.0F, 1.0F, 14.0F, 16.0F, 0.0F, true); head_exterior.setTextureOffset(252, 31).addCuboid(-18.0F, -43.9F, 8.0F, 36.0F, 12.0F, 26.0F, 0.0F, false); outer_roof_1_r3 = new ModelPart(this); outer_roof_1_r3.setPivot(-20.0F, -14.0F, 0.0F); head_exterior.addChild(outer_roof_1_r3); setRotationAngle(outer_roof_1_r3, 0.0F, 0.0F, 0.1107F); outer_roof_1_r3.setTextureOffset(76, 319).addCuboid(-1.0F, -26.0F, -16.0F, 1.0F, 8.0F, 49.0F, 0.0F, false); outer_roof_1_r3.setTextureOffset(286, 86).addCuboid(0.0F, -19.0F, -18.0F, 2.0F, 19.0F, 36.0F, 0.0F, false); outer_roof_2_r5 = new ModelPart(this); outer_roof_2_r5.setPivot(20.0F, -14.0F, 0.0F); head_exterior.addChild(outer_roof_2_r5); setRotationAngle(outer_roof_2_r5, 0.0F, 0.0F, -0.1107F); outer_roof_2_r5.setTextureOffset(76, 319).addCuboid(0.0F, -26.0F, -16.0F, 1.0F, 8.0F, 49.0F, 0.0F, true); outer_roof_2_r5.setTextureOffset(286, 192).addCuboid(-2.0F, -19.0F, -18.0F, 2.0F, 19.0F, 36.0F, 0.0F, true); driver_door_top_2_r1 = new ModelPart(this); driver_door_top_2_r1.setPivot(20.8F, -14.0F, 16.0F); head_exterior.addChild(driver_door_top_2_r1); setRotationAngle(driver_door_top_2_r1, 0.0F, 0.0F, -0.1107F); driver_door_top_2_r1.setTextureOffset(116, 178).addCuboid(-1.0F, -19.0F, 0.0F, 1.0F, 19.0F, 16.0F, 0.0F, true); driver_door_top_1_r1 = new ModelPart(this); driver_door_top_1_r1.setPivot(-20.8F, -14.0F, 16.0F); head_exterior.addChild(driver_door_top_1_r1); setRotationAngle(driver_door_top_1_r1, 0.0F, 0.0F, 0.1107F); driver_door_top_1_r1.setTextureOffset(194, 122).addCuboid(0.0F, -19.0F, 0.0F, 1.0F, 19.0F, 16.0F, 0.0F, false); floor_2_r1 = new ModelPart(this); floor_2_r1.setPivot(0.0F, 0.0F, 0.0F); head_exterior.addChild(floor_2_r1); setRotationAngle(floor_2_r1, 0.0F, 3.1416F, 0.0F); floor_2_r1.setTextureOffset(58, 188).addCuboid(-21.0F, 0.0F, -8.0F, 1.0F, 7.0F, 24.0F, 0.0F, false); front = new ModelPart(this); front.setPivot(0.0F, 0.0F, 0.0F); head_exterior.addChild(front); front_middle_r1_r1 = new ModelPart(this); front_middle_r1_r1.setPivot(0.0F, 2.5717F, 45.8123F); front.addChild(front_middle_r1_r1); setRotationAngle(front_middle_r1_r1, 0.3491F, 0.0F, 0.0F); front_middle_r1_r1.setTextureOffset(0, 66).addCuboid(-10.0F, -44.5717F, 8.1877F, 20.0F, 44.0F, 0.0F, 0.0F, false); front_roof_r1_r1 = new ModelPart(this); front_roof_r1_r1.setPivot(0.0F, -44.0F, 34.0F); front.addChild(front_roof_r1_r1); setRotationAngle(front_roof_r1_r1, 1.0472F, 0.0F, 0.0F); front_roof_r1_r1.setTextureOffset(224, 12).addCuboid(-6.0F, 0.0F, 0.0F, 12.0F, 6.0F, 0.0F, 0.0F, false); bottom_r1_r1 = new ModelPart(this); bottom_r1_r1.setPivot(0.0F, 7.0F, 32.0F); front.addChild(bottom_r1_r1); setRotationAngle(bottom_r1_r1, -1.3526F, 0.0F, 0.0F); bottom_r1_r1.setTextureOffset(332, 0).addCuboid(-21.0F, -22.0F, 0.0F, 42.0F, 22.0F, 0.0F, 0.0F, false); front_bottom_r1_r1 = new ModelPart(this); front_bottom_r1_r1.setPivot(0.0F, -9.1588F, 1.0997F); front.addChild(front_bottom_r1_r1); setRotationAngle(front_bottom_r1_r1, -0.1745F, 0.0F, 0.0F); front_bottom_r1_r1.setTextureOffset(0, 59).addCuboid(-10.0F, -0.7936F, 52.9026F, 20.0F, 5.0F, 0.0F, 0.0F, false); front_side_1_r1_r1 = new ModelPart(this); front_side_1_r1_r1.setPivot(-13.6605F, -21.1866F, 43.5706F); front.addChild(front_side_1_r1_r1); setRotationAngle(front_side_1_r1_r1, 0.3491F, -0.5236F, -0.0873F); front_side_1_r1_r1.setTextureOffset(0, 265).addCuboid(-6.5F, -22.0F, 0.0F, 13.0F, 44.0F, 0.0F, 0.0F, false); front_side_2_r1_r1 = new ModelPart(this); front_side_2_r1_r1.setPivot(13.6605F, -21.1866F, 43.5706F); front.addChild(front_side_2_r1_r1); setRotationAngle(front_side_2_r1_r1, 0.3491F, 0.5236F, 0.0873F); front_side_2_r1_r1.setTextureOffset(192, 251).addCuboid(-6.5F, -22.0F, 0.0F, 13.0F, 44.0F, 0.0F, 0.0F, false); bottom_side_1_r1_r1 = new ModelPart(this); bottom_side_1_r1_r1.setPivot(-20.8F, -14.0F, 32.0F); front.addChild(bottom_side_1_r1_r1); setRotationAngle(bottom_side_1_r1_r1, 0.0F, -1.309F, 0.0F); bottom_side_1_r1_r1.setTextureOffset(200, 82).addCuboid(0.0F, 0.0F, 0.0F, 19.0F, 21.0F, 0.0F, 0.0F, false); bottom_side_2_r1_r1 = new ModelPart(this); bottom_side_2_r1_r1.setPivot(20.8F, -14.0F, 32.0F); front.addChild(bottom_side_2_r1_r1); setRotationAngle(bottom_side_2_r1_r1, 0.0F, 1.309F, 0.0F); bottom_side_2_r1_r1.setTextureOffset(130, 148).addCuboid(-19.0F, 0.0F, 0.0F, 19.0F, 21.0F, 0.0F, 0.0F, false); top_side_1_r1_r1 = new ModelPart(this); top_side_1_r1_r1.setPivot(-20.8F, -14.0F, 32.0F); front.addChild(top_side_1_r1_r1); setRotationAngle(top_side_1_r1_r1, 0.0F, -1.309F, 0.1107F); top_side_1_r1_r1.setTextureOffset(252, 69).addCuboid(0.0F, -26.0F, 0.0F, 13.0F, 26.0F, 0.0F, 0.0F, false); top_side_2_r1_r1 = new ModelPart(this); top_side_2_r1_r1.setPivot(20.8F, -14.0F, 32.0F); front.addChild(top_side_2_r1_r1); setRotationAngle(top_side_2_r1_r1, 0.0F, 1.309F, -0.1107F); top_side_2_r1_r1.setTextureOffset(228, 192).addCuboid(-13.0F, -26.0F, 0.0F, 13.0F, 26.0F, 0.0F, 0.0F, false); roof_side_1_r1_r1 = new ModelPart(this); roof_side_1_r1_r1.setPivot(-6.0F, -44.0F, 34.0F); front.addChild(roof_side_1_r1_r1); setRotationAngle(roof_side_1_r1_r1, 1.0472F, 0.0F, -0.1745F); roof_side_1_r1_r1.setTextureOffset(224, 6).addCuboid(-8.0F, 0.0F, 0.0F, 8.0F, 6.0F, 0.0F, 0.0F, false); roof_side_2_r1_r1 = new ModelPart(this); roof_side_2_r1_r1.setPivot(6.0F, -44.0F, 34.0F); front.addChild(roof_side_2_r1_r1); setRotationAngle(roof_side_2_r1_r1, 1.0472F, 0.0F, 0.1745F); roof_side_2_r1_r1.setTextureOffset(224, 0).addCuboid(0.0F, 0.0F, 0.0F, 8.0F, 6.0F, 0.0F, 0.0F, false); roof_middle_corner_1_r1_r1 = new ModelPart(this); roof_middle_corner_1_r1_r1.setPivot(-14.8022F, -41.2114F, 35.299F); front.addChild(roof_middle_corner_1_r1_r1); setRotationAngle(roof_middle_corner_1_r1_r1, 1.0472F, 0.0F, -0.5236F); roof_middle_corner_1_r1_r1.setTextureOffset(0, 52).addCuboid(-1.5F, -1.5F, 0.0F, 3.0F, 3.0F, 0.0F, 0.0F, false); roof_middle_corner_2_r1_r1 = new ModelPart(this); roof_middle_corner_2_r1_r1.setPivot(14.8022F, -41.2114F, 35.299F); front.addChild(roof_middle_corner_2_r1_r1); setRotationAngle(roof_middle_corner_2_r1_r1, 1.0472F, 0.0F, 0.5236F); roof_middle_corner_2_r1_r1.setTextureOffset(0, 55).addCuboid(-1.5F, -1.5F, 0.0F, 3.0F, 3.0F, 0.0F, 0.0F, false); roof_corner_1_r1_r1 = new ModelPart(this); roof_corner_1_r1_r1.setPivot(-16.7925F, -39.5614F, 34.8655F); front.addChild(roof_corner_1_r1_r1); setRotationAngle(roof_corner_1_r1_r1, 1.0472F, 0.0F, -1.0472F); roof_corner_1_r1_r1.setTextureOffset(30, 30).addCuboid(-1.5F, -1.0F, 0.0F, 3.0F, 2.0F, 0.0F, 0.0F, false); roof_corner_2_r1_r1 = new ModelPart(this); roof_corner_2_r1_r1.setPivot(16.7929F, -39.5622F, 34.866F); front.addChild(roof_corner_2_r1_r1); setRotationAngle(roof_corner_2_r1_r1, 1.0472F, 0.0F, 1.0472F); roof_corner_2_r1_r1.setTextureOffset(24, 30).addCuboid(-1.5F, -1.0F, 0.0F, 3.0F, 2.0F, 0.0F, 0.0F, false); bottom_corner_1_r1_r1 = new ModelPart(this); bottom_corner_1_r1_r1.setPivot(21.913F, -11.9098F, 14.4897F); front.addChild(bottom_corner_1_r1_r1); setRotationAngle(bottom_corner_1_r1_r1, -0.1745F, -0.5236F, -0.0873F); bottom_corner_1_r1_r1.setTextureOffset(114, 37).addCuboid(-17.951F, -0.4819F, 50.7099F, 9.0F, 5.0F, 0.0F, 0.0F, false); bottom_corner_2_r1_r1 = new ModelPart(this); bottom_corner_2_r1_r1.setPivot(-21.913F, -11.9098F, 14.4897F); front.addChild(bottom_corner_2_r1_r1); setRotationAngle(bottom_corner_2_r1_r1, -0.1745F, 0.5236F, 0.0873F); bottom_corner_2_r1_r1.setTextureOffset(114, 32).addCuboid(8.951F, -0.4819F, 50.7099F, 9.0F, 5.0F, 0.0F, 0.0F, false); top_handrail_head_sp1900 = new ModelPart(this); top_handrail_head_sp1900.setPivot(0.0F, 24.0F, 0.0F); top_handrail_head_sp1900.setTextureOffset(0, 0).addCuboid(-5.0F, -36.0F, 9.8F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_head_sp1900.setTextureOffset(0, 0).addCuboid(-5.0F, -36.0F, -9.8F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_bottom_left_r3 = new ModelPart(this); top_handrail_bottom_left_r3.setPivot(-5.0F, -31.0876F, 3.8875F); top_handrail_head_sp1900.addChild(top_handrail_bottom_left_r3); setRotationAngle(top_handrail_bottom_left_r3, -1.5708F, 0.0F, 0.0F); top_handrail_bottom_left_r3.setTextureOffset(0, 0).addCuboid(0.0F, -4.0F, 0.0F, 0.0F, 8.0F, 0.0F, 0.2F, false); top_handrail_bottom_right_r3 = new ModelPart(this); top_handrail_bottom_right_r3.setPivot(-5.0F, -31.0876F, -3.8876F); top_handrail_head_sp1900.addChild(top_handrail_bottom_right_r3); setRotationAngle(top_handrail_bottom_right_r3, -1.5708F, 0.0F, 0.0F); top_handrail_bottom_right_r3.setTextureOffset(0, 0).addCuboid(0.0F, -4.0F, 0.0F, 0.0F, 8.0F, 0.0F, 0.2F, false); top_handrail_right_3_r3 = new ModelPart(this); top_handrail_right_3_r3.setPivot(-5.0F, -31.4108F, -8.5938F); top_handrail_head_sp1900.addChild(top_handrail_right_3_r3); setRotationAngle(top_handrail_right_3_r3, 1.0472F, 0.0F, 0.0F); top_handrail_right_3_r3.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, false); top_handrail_right_2_r2 = new ModelPart(this); top_handrail_right_2_r2.setPivot(-4.8F, -32.8F, -10.0F); top_handrail_head_sp1900.addChild(top_handrail_right_2_r2); setRotationAngle(top_handrail_right_2_r2, 0.5236F, 0.0F, 0.0F); top_handrail_right_2_r2.setTextureOffset(0, 0).addCuboid(-0.2F, 0.2F, 0.2F, 0.0F, 1.0F, 0.0F, 0.2F, false); top_handrail_left_3_r3 = new ModelPart(this); top_handrail_left_3_r3.setPivot(-5.0F, -31.4108F, 8.5938F); top_handrail_head_sp1900.addChild(top_handrail_left_3_r3); setRotationAngle(top_handrail_left_3_r3, -1.0472F, 0.0F, 0.0F); top_handrail_left_3_r3.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, false); top_handrail_left_2_r2 = new ModelPart(this); top_handrail_left_2_r2.setPivot(-4.8F, -32.8F, 10.0F); top_handrail_head_sp1900.addChild(top_handrail_left_2_r2); setRotationAngle(top_handrail_left_2_r2, -0.5236F, 0.0F, 0.0F); top_handrail_left_2_r2.setTextureOffset(0, 0).addCuboid(-0.2F, 0.2F, -0.2F, 0.0F, 1.0F, 0.0F, 0.2F, false); handrail_strap_head = new ModelPart(this); handrail_strap_head.setPivot(0.0F, 0.0F, 0.0F); top_handrail_head_sp1900.addChild(handrail_strap_head); handrail_strap_head.setTextureOffset(12, 12).addCuboid(-6.0F, -32.0F, -6.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_head.setTextureOffset(12, 12).addCuboid(-6.0F, -32.0F, 0.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_head.setTextureOffset(12, 12).addCuboid(-6.0F, -32.0F, 6.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); top_handrail_head_c1141a = new ModelPart(this); top_handrail_head_c1141a.setPivot(0.0F, 24.0F, 0.0F); top_handrail_head_c1141a.setTextureOffset(0, 50).addCuboid(-5.0F, -31.0F, 15.8F, 5.0F, 0.0F, 0.0F, 0.2F, false); top_handrail_head_c1141a.setTextureOffset(0, 50).addCuboid(0.0F, -31.0F, 15.8F, 5.0F, 0.0F, 0.0F, 0.2F, true); top_handrail_head_c1141a.setTextureOffset(0, 0).addCuboid(-4.727F, -36.6045F, -3.1124F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_head_c1141a.setTextureOffset(0, 0).addCuboid(4.727F, -36.6045F, -3.1124F, 0.0F, 3.0F, 0.0F, 0.2F, true); top_handrail_head_c1141a.setTextureOffset(0, 0).addCuboid(-4.727F, -36.6045F, 11.0F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_head_c1141a.setTextureOffset(0, 0).addCuboid(4.727F, -36.6045F, 11.0F, 0.0F, 3.0F, 0.0F, 0.2F, true); top_handrail_head_c1141a.setTextureOffset(0, 0).addCuboid(0.0F, -36.6046F, 13.6145F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_head_c1141a.setTextureOffset(0, 0).addCuboid(0.0F, -36.0F, 11.0F, 0.0F, 7.0F, 0.0F, 0.2F, false); top_handrail_head_c1141a.setTextureOffset(8, 7).addCuboid(0.0F, -23.2645F, 10.437F, 0.0F, 6.0F, 0.0F, 0.2F, false); top_handrail_head_c1141a.setTextureOffset(8, 7).addCuboid(0.0F, -23.2645F, 11.563F, 0.0F, 6.0F, 0.0F, 0.2F, false); top_handrail_head_c1141a.setTextureOffset(0, 0).addCuboid(0.0F, -12.0F, 11.0F, 0.0F, 12.0F, 0.0F, 0.2F, false); pole_bottom_diagonal_3_r1 = new ModelPart(this); pole_bottom_diagonal_3_r1.setPivot(0.0F, -14.4002F, 11.2819F); top_handrail_head_c1141a.addChild(pole_bottom_diagonal_3_r1); setRotationAngle(pole_bottom_diagonal_3_r1, -0.1047F, 0.0F, 0.0F); pole_bottom_diagonal_3_r1.setTextureOffset(11, 28).addCuboid(0.0F, -2.5F, 0.0F, 0.0F, 5.0F, 0.0F, 0.2F, false); pole_bottom_diagonal_2_r2 = new ModelPart(this); pole_bottom_diagonal_2_r2.setPivot(0.0F, -14.4002F, 10.7181F); top_handrail_head_c1141a.addChild(pole_bottom_diagonal_2_r2); setRotationAngle(pole_bottom_diagonal_2_r2, 0.1047F, 0.0F, 0.0F); pole_bottom_diagonal_2_r2.setTextureOffset(11, 28).addCuboid(0.0F, -2.5F, 0.0F, 0.0F, 5.0F, 0.0F, 0.2F, false); pole_top_diagonal_3_r1 = new ModelPart(this); pole_top_diagonal_3_r1.setPivot(0.2F, -28.8F, 10.8F); top_handrail_head_c1141a.addChild(pole_top_diagonal_3_r1); setRotationAngle(pole_top_diagonal_3_r1, 0.1047F, 0.0F, 0.0F); pole_top_diagonal_3_r1.setTextureOffset(11, 11).addCuboid(-0.2F, 0.2069F, 0.2F, 0.0F, 5.0F, 0.0F, 0.2F, false); pole_top_diagonal_2_r2 = new ModelPart(this); pole_top_diagonal_2_r2.setPivot(0.2F, -28.8F, 11.2F); top_handrail_head_c1141a.addChild(pole_top_diagonal_2_r2); setRotationAngle(pole_top_diagonal_2_r2, -0.1047F, 0.0F, 0.0F); pole_top_diagonal_2_r2.setTextureOffset(11, 11).addCuboid(-0.2F, 0.2069F, -0.2F, 0.0F, 5.0F, 0.0F, 0.2F, false); top_handrail_connector_bottom_5_r1 = new ModelPart(this); top_handrail_connector_bottom_5_r1.setPivot(0.0F, -32.2308F, 14.6605F); top_handrail_head_c1141a.addChild(top_handrail_connector_bottom_5_r1); setRotationAngle(top_handrail_connector_bottom_5_r1, 0.6981F, 0.0F, 0.0F); top_handrail_connector_bottom_5_r1.setTextureOffset(0, 0).addCuboid(0.0F, -1.5F, 0.0F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_connector_bottom_right_4_r1 = new ModelPart(this); top_handrail_connector_bottom_right_4_r1.setPivot(5.7729F, -32.2308F, 0.0F); top_handrail_head_c1141a.addChild(top_handrail_connector_bottom_right_4_r1); setRotationAngle(top_handrail_connector_bottom_right_4_r1, 0.0F, 0.0F, -0.6981F); top_handrail_connector_bottom_right_4_r1.setTextureOffset(0, 0).addCuboid(0.0F, -1.5F, 11.0F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_connector_bottom_left_4_r1 = new ModelPart(this); top_handrail_connector_bottom_left_4_r1.setPivot(-5.7729F, -32.2308F, 0.0F); top_handrail_head_c1141a.addChild(top_handrail_connector_bottom_left_4_r1); setRotationAngle(top_handrail_connector_bottom_left_4_r1, 0.0F, 0.0F, 0.6981F); top_handrail_connector_bottom_left_4_r1.setTextureOffset(0, 0).addCuboid(0.0F, -1.5F, 11.0F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_connector_bottom_right_3_r1 = new ModelPart(this); top_handrail_connector_bottom_right_3_r1.setPivot(5.7729F, -32.2308F, 0.0F); top_handrail_head_c1141a.addChild(top_handrail_connector_bottom_right_3_r1); setRotationAngle(top_handrail_connector_bottom_right_3_r1, 0.0F, 0.0F, -0.6981F); top_handrail_connector_bottom_right_3_r1.setTextureOffset(0, 0).addCuboid(0.0F, -1.5F, -3.1124F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_connector_bottom_left_3_r1 = new ModelPart(this); top_handrail_connector_bottom_left_3_r1.setPivot(-5.7729F, -32.2308F, 0.0F); top_handrail_head_c1141a.addChild(top_handrail_connector_bottom_left_3_r1); setRotationAngle(top_handrail_connector_bottom_left_3_r1, 0.0F, 0.0F, 0.6981F); top_handrail_connector_bottom_left_3_r1.setTextureOffset(0, 0).addCuboid(0.0F, -1.5F, -3.1124F, 0.0F, 3.0F, 0.0F, 0.2F, false); top_handrail_bottom_right_r4 = new ModelPart(this); top_handrail_bottom_right_r4.setPivot(6.9124F, -31.0F, 6.8876F); top_handrail_head_c1141a.addChild(top_handrail_bottom_right_r4); setRotationAngle(top_handrail_bottom_right_r4, -1.5708F, 0.0F, 0.0F); top_handrail_bottom_right_r4.setTextureOffset(0, 0).addCuboid(0.0F, -7.0F, 0.0F, 0.0F, 17.0F, 0.0F, 0.2F, true); top_handrail_bottom_right_r4.setTextureOffset(0, 0).addCuboid(-13.8249F, -7.0F, 0.0F, 0.0F, 17.0F, 0.0F, 0.2F, false); top_handrail_right_5_r1 = new ModelPart(this); top_handrail_right_5_r1.setPivot(6.5892F, -31.0F, 14.5938F); top_handrail_head_c1141a.addChild(top_handrail_right_5_r1); setRotationAngle(top_handrail_right_5_r1, -1.5708F, -0.5236F, 0.0F); top_handrail_right_5_r1.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, true); top_handrail_right_4_r2 = new ModelPart(this); top_handrail_right_4_r2.setPivot(5.7062F, -31.0F, 15.4768F); top_handrail_head_c1141a.addChild(top_handrail_right_4_r2); setRotationAngle(top_handrail_right_4_r2, -1.5708F, -1.0472F, 0.0F); top_handrail_right_4_r2.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, true); top_handrail_left_5_r1 = new ModelPart(this); top_handrail_left_5_r1.setPivot(-6.5892F, -31.0F, 14.5938F); top_handrail_head_c1141a.addChild(top_handrail_left_5_r1); setRotationAngle(top_handrail_left_5_r1, -1.5708F, 0.5236F, 0.0F); top_handrail_left_5_r1.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, false); top_handrail_left_4_r2 = new ModelPart(this); top_handrail_left_4_r2.setPivot(-5.7062F, -31.0F, 15.4768F); top_handrail_head_c1141a.addChild(top_handrail_left_4_r2); setRotationAngle(top_handrail_left_4_r2, -1.5708F, 1.0472F, 0.0F); top_handrail_left_4_r2.setTextureOffset(0, 0).addCuboid(0.0F, -0.5F, 0.0F, 0.0F, 1.0F, 0.0F, 0.2F, false); handrail_strap_3 = new ModelPart(this); handrail_strap_3.setPivot(0.0F, 0.0F, 0.0F); top_handrail_head_c1141a.addChild(handrail_strap_3); handrail_strap_3.setTextureOffset(12, 12).addCuboid(-8.0F, -32.0F, -1.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_3.setTextureOffset(12, 12).addCuboid(6.0F, -32.0F, -1.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_3.setTextureOffset(12, 12).addCuboid(-8.0F, -32.0F, 4.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_3.setTextureOffset(12, 12).addCuboid(6.0F, -32.0F, 4.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_3.setTextureOffset(12, 12).addCuboid(-8.0F, -32.0F, 9.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_3.setTextureOffset(12, 12).addCuboid(6.0F, -32.0F, 9.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_3.setTextureOffset(12, 12).addCuboid(-8.0F, -32.0F, 14.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_3.setTextureOffset(12, 12).addCuboid(6.0F, -32.0F, 14.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_right_8_r1 = new ModelPart(this); handrail_strap_right_8_r1.setPivot(0.0F, 0.0F, 0.0F); handrail_strap_3.addChild(handrail_strap_right_8_r1); setRotationAngle(handrail_strap_right_8_r1, 0.0F, 1.5708F, 0.0F); handrail_strap_right_8_r1.setTextureOffset(12, 12).addCuboid(-16.8F, -32.0F, 3.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); handrail_strap_left_8_r1 = new ModelPart(this); handrail_strap_left_8_r1.setPivot(0.0F, 0.0F, 0.0F); handrail_strap_3.addChild(handrail_strap_left_8_r1); setRotationAngle(handrail_strap_left_8_r1, 0.0F, -1.5708F, 0.0F); handrail_strap_left_8_r1.setTextureOffset(12, 12).addCuboid(14.8F, -32.0F, 3.0F, 2.0F, 4.0F, 0.0F, 0.0F, false); headlights = new ModelPart(this); headlights.setPivot(0.0F, 24.0F, 0.0F); headlight_4_r1_r1 = new ModelPart(this); headlight_4_r1_r1.setPivot(17.943F, 10.9921F, 21.2198F); headlights.addChild(headlight_4_r1_r1); setRotationAngle(headlight_4_r1_r1, 0.3491F, -0.5236F, -0.0873F); headlight_4_r1_r1.setTextureOffset(16, 34).addCuboid(-12.0F, -15.5F, 43.4F, 4.0F, 6.0F, 0.0F, 0.0F, true); headlight_3_r1_r1 = new ModelPart(this); headlight_3_r1_r1.setPivot(0.0F, 14.3777F, 10.093F); headlights.addChild(headlight_3_r1_r1); setRotationAngle(headlight_3_r1_r1, 0.3491F, 0.0F, 0.0F); headlight_3_r1_r1.setTextureOffset(18, 16).addCuboid(-12.0F, -16.0F, 45.7F, 7.0F, 6.0F, 0.0F, 0.0F, true); headlight_3_r1_r1.setTextureOffset(18, 16).addCuboid(5.0F, -16.0F, 45.7F, 7.0F, 6.0F, 0.0F, 0.0F, false); headlight_1_r1_r1 = new ModelPart(this); headlight_1_r1_r1.setPivot(-17.943F, 10.9921F, 21.2198F); headlights.addChild(headlight_1_r1_r1); setRotationAngle(headlight_1_r1_r1, 0.3491F, 0.5236F, 0.0873F); headlight_1_r1_r1.setTextureOffset(16, 34).addCuboid(8.0F, -15.5F, 43.4F, 4.0F, 6.0F, 0.0F, 0.0F, false); tail_lights = new ModelPart(this); tail_lights.setPivot(0.0F, 24.0F, 0.0F); tail_light_4_r1_r1 = new ModelPart(this); tail_light_4_r1_r1.setPivot(17.943F, 10.9921F, 21.2198F); tail_lights.addChild(tail_light_4_r1_r1); setRotationAngle(tail_light_4_r1_r1, 0.3491F, -0.5236F, -0.0873F); tail_light_4_r1_r1.setTextureOffset(16, 40).addCuboid(-12.0F, -15.5F, 43.4F, 4.0F, 6.0F, 0.0F, 0.0F, true); tail_light_3_r1_r1 = new ModelPart(this); tail_light_3_r1_r1.setPivot(0.0F, 14.3777F, 10.093F); tail_lights.addChild(tail_light_3_r1_r1); setRotationAngle(tail_light_3_r1_r1, 0.3491F, 0.0F, 0.0F); tail_light_3_r1_r1.setTextureOffset(18, 22).addCuboid(-12.0F, -16.0F, 45.7F, 7.0F, 6.0F, 0.0F, 0.0F, true); tail_light_3_r1_r1.setTextureOffset(18, 22).addCuboid(5.0F, -16.0F, 45.7F, 7.0F, 6.0F, 0.0F, 0.0F, false); tail_light_1_r1_r1 = new ModelPart(this); tail_light_1_r1_r1.setPivot(-17.943F, 10.9921F, 21.2198F); tail_lights.addChild(tail_light_1_r1_r1); setRotationAngle(tail_light_1_r1_r1, 0.3491F, 0.5236F, 0.0873F); tail_light_1_r1_r1.setTextureOffset(16, 40).addCuboid(8.0F, -15.5F, 43.4F, 4.0F, 6.0F, 0.0F, 0.0F, false); bb_main = new ModelPart(this); bb_main.setPivot(0.0F, 24.0F, 0.0F); bb_main.setTextureOffset(4, 0).addCuboid(0.0F, -36.0F, 0.0F, 0.0F, 36.0F, 0.0F, 0.2F, false); } private static final int DOOR_MAX = 14; private static final ModelDoorOverlay MODEL_DOOR_OVERLAY = new ModelDoorOverlay(); @Override protected void renderWindowPositions(MatrixStack matrices, VertexConsumer vertices, RenderStage renderStage, int light, int position, boolean isEnd1Head, boolean isEnd2Head) { switch (renderStage) { case LIGHTS: renderMirror(isC1141A ? roof_light_c1141a : roof_light_sp1900, matrices, vertices, light, position); break; case INTERIOR: renderMirror(window, matrices, vertices, light, position); renderMirror(isC1141A ? roof_c1141a : roof_sp1900, matrices, vertices, light, position); renderMirror(isC1141A ? top_handrail_c1141a : top_handrail_sp1900, matrices, vertices, light, position); break; case INTERIOR_TRANSLUCENT: if (isC1141A) { renderMirror(side_panel_c1141a, matrices, vertices, light, position - 12); renderMirror(side_panel_c1141a, matrices, vertices, light, position + 12); } else { renderMirror(side_panel_sp1900, matrices, vertices, light, position - 15.9F); renderMirror(side_panel_sp1900, matrices, vertices, light, position + 15.9F); } break; case EXTERIOR: if (isEnd2Head) { renderOnceFlipped(window_exterior_1, matrices, vertices, light, position); renderOnceFlipped(window_exterior_2, matrices, vertices, light, position); } else { renderOnce(window_exterior_1, matrices, vertices, light, position); renderOnce(window_exterior_2, matrices, vertices, light, position); } renderMirror(roof_exterior, matrices, vertices, light, position); break; } } @Override protected void renderDoorPositions(MatrixStack matrices, VertexConsumer vertices, RenderStage renderStage, int light, int position, float doorLeftValue, float doorRightValue, boolean isEnd1Head, boolean isEnd2Head) { final float doorLeft = doorLeftValue * DOOR_MAX; final float doorRight = doorRightValue * DOOR_MAX; switch (renderStage) { case LIGHTS: renderMirror(isC1141A ? roof_light_c1141a : roof_light_sp1900, matrices, vertices, light, position); if (isC1141A) { renderMirror(door_light_c1141a, matrices, vertices, light, position); } break; case INTERIOR: door_left.setPivot(0, 0, doorRight); door_right.setPivot(0, 0, -doorRight); renderOnce(door, matrices, vertices, light, position); door_left.setPivot(0, 0, doorLeft); door_right.setPivot(0, 0, -doorLeft); renderOnceFlipped(door, matrices, vertices, light, position); renderMirror(isC1141A ? roof_c1141a : roof_sp1900, matrices, vertices, light, position); if (!isC1141A) { if (getDoorPositions().length > 3 && (position == getDoorPositions()[1] || position == getDoorPositions()[3])) { renderOnce(bb_main, matrices, vertices, light, position); } else { renderOnce(tv_pole, matrices, vertices, light, position); } } break; case EXTERIOR: if (isEnd2Head) { door_left_exterior_2.setPivot(0, 0, doorLeft); door_right_exterior_2.setPivot(0, 0, -doorLeft); renderOnceFlipped(door_exterior_2, matrices, vertices, light, position); door_left_exterior_1.setPivot(0, 0, -doorRight); door_right_exterior_1.setPivot(0, 0, doorRight); renderOnceFlipped(door_exterior_1, matrices, vertices, light, position); } else { door_left_exterior_1.setPivot(0, 0, -doorLeft); door_right_exterior_1.setPivot(0, 0, doorLeft); renderOnce(door_exterior_1, matrices, vertices, light, position); door_left_exterior_2.setPivot(0, 0, doorRight); door_right_exterior_2.setPivot(0, 0, -doorRight); renderOnce(door_exterior_2, matrices, vertices, light, position); } renderMirror(roof_exterior, matrices, vertices, light, position); break; } } @Override protected void renderHeadPosition1(MatrixStack matrices, VertexConsumer vertices, RenderStage renderStage, int light, int position, boolean useHeadlights) { switch (renderStage) { case LIGHTS: renderOnce(isC1141A ? roof_end_light_c1141a : roof_end_light_sp1900, matrices, vertices, light, position); renderOnceFlipped(useHeadlights ? headlights : tail_lights, matrices, vertices, light, position); break; case INTERIOR: renderOnceFlipped(head, matrices, vertices, light, position); renderOnce(isC1141A ? roof_end_c1141a : roof_end_sp1900, matrices, vertices, light, position); if (!isC1141A) { renderMirror(top_handrail_head_sp1900, matrices, vertices, light, position + 6); } break; case INTERIOR_TRANSLUCENT: if (isC1141A) { renderMirror(side_panel_c1141a, matrices, vertices, light, position + 16); } else { renderMirror(side_panel_sp1900, matrices, vertices, light, position + 15.9F); } break; case EXTERIOR: renderOnceFlipped(head_exterior, matrices, vertices, light, position); renderOnce(roof_end_exterior, matrices, vertices, light, position + 2); break; } } @Override protected void renderHeadPosition2(MatrixStack matrices, VertexConsumer vertices, RenderStage renderStage, int light, int position, boolean useHeadlights) { switch (renderStage) { case LIGHTS: renderOnce(isC1141A ? roof_end_light_c1141a : roof_end_light_sp1900, matrices, vertices, light, position); renderOnce(useHeadlights ? headlights : tail_lights, matrices, vertices, light, position); break; case INTERIOR: renderOnce(head, matrices, vertices, light, position); renderOnceFlipped(isC1141A ? roof_end_c1141a : roof_end_sp1900, matrices, vertices, light, position); if (!isC1141A) { renderMirror(top_handrail_head_sp1900, matrices, vertices, light, position - 6); } break; case INTERIOR_TRANSLUCENT: if (isC1141A) { renderMirror(side_panel_c1141a, matrices, vertices, light, position - 16); } else { renderMirror(side_panel_sp1900, matrices, vertices, light, position - 15.9F); } break; case EXTERIOR: renderOnce(head_exterior, matrices, vertices, light, position); renderOnceFlipped(roof_end_exterior, matrices, vertices, light, position - 2); break; } } @Override protected void renderEndPosition1(MatrixStack matrices, VertexConsumer vertices, RenderStage renderStage, int light, int position) { switch (renderStage) { case LIGHTS: renderOnce(isC1141A ? roof_end_light_c1141a : roof_end_light_sp1900, matrices, vertices, light, position); break; case INTERIOR: renderOnce(end, matrices, vertices, light, position); renderOnce(isC1141A ? roof_end_c1141a : roof_end_sp1900, matrices, vertices, light, position); if (isC1141A) { renderOnce(top_handrail_head_c1141a, matrices, vertices, light, position); } else { renderMirror(top_handrail_sp1900, matrices, vertices, light, position); } break; case INTERIOR_TRANSLUCENT: if (isC1141A) { renderMirror(side_panel_c1141a, matrices, vertices, light, position + 16); } else { renderMirror(side_panel_sp1900, matrices, vertices, light, position + 15.9F); } break; case EXTERIOR: renderOnce(end_exterior, matrices, vertices, light, position); renderOnce(roof_end_exterior, matrices, vertices, light, position); break; } } @Override protected void renderEndPosition2(MatrixStack matrices, VertexConsumer vertices, RenderStage renderStage, int light, int position) { switch (renderStage) { case LIGHTS: renderOnceFlipped(isC1141A ? roof_end_light_c1141a : roof_end_light_sp1900, matrices, vertices, light, position); break; case INTERIOR: renderOnceFlipped(end, matrices, vertices, light, position); renderOnceFlipped(isC1141A ? roof_end_c1141a : roof_end_sp1900, matrices, vertices, light, position); if (isC1141A) { renderOnceFlipped(top_handrail_head_c1141a, matrices, vertices, light, position); } else { renderMirror(top_handrail_sp1900, matrices, vertices, light, position); } break; case INTERIOR_TRANSLUCENT: if (isC1141A) { renderMirror(side_panel_c1141a, matrices, vertices, light, position - 16); } else { renderMirror(side_panel_sp1900, matrices, vertices, light, position - 15.9F); } break; case EXTERIOR: renderOnceFlipped(end_exterior, matrices, vertices, light, position); renderOnceFlipped(roof_end_exterior, matrices, vertices, light, position); break; } } @Override protected ModelDoorOverlayBase getModelDoorOverlay() { return MODEL_DOOR_OVERLAY; } @Override protected int[] getWindowPositions() { return new int[]{-96, -32, 32, 96}; } @Override protected int[] getDoorPositions() { return new int[]{-128, -64, 0, 64, 128}; } @Override protected int[] getEndPositions() { return new int[]{-160, 160}; } private static class ModelDoorOverlay extends ModelDoorOverlayBase { private final ModelPart door_left_overlay_interior; private final ModelPart door_left_top_r1; private final ModelPart door_right_overlay_interior; private final ModelPart door_right_top_r1; private final ModelPart door_right_bottom_r1; private final ModelPart door_left_overlay_exterior; private final ModelPart door_left_top_r2; private final ModelPart door_right_overlay_exterior; private final ModelPart door_right_top_r2; private final ModelPart outer_roof_1; private final ModelPart outer_roof_1_r1; private final ModelPart outer_roof_2; private final ModelPart outer_roof_2_r1; private final ModelPart wall_1; private final ModelPart upper_wall_1_r1; private final ModelPart wall_2; private final ModelPart upper_wall_2_r1; public ModelDoorOverlay() { textureWidth = 32; textureHeight = 32; door_left_overlay_interior = new ModelPart(this); door_left_overlay_interior.setPivot(0.0F, 24.0F, 0.0F); door_left_overlay_interior.setTextureOffset(0, 3).addCuboid(-19.7F, -14.0F, 0.0F, 0.0F, 12.0F, 16.0F, 0.0F, false); door_left_top_r1 = new ModelPart(this); door_left_top_r1.setPivot(-20.8F, -14.0F, 0.0F); door_left_overlay_interior.addChild(door_left_top_r1); setRotationAngle(door_left_top_r1, 0.0F, 0.0F, 0.1107F); door_left_top_r1.setTextureOffset(0, -16).addCuboid(1.1F, -19.0F, 0.0F, 0.0F, 19.0F, 16.0F, 0.0F, false); door_right_overlay_interior = new ModelPart(this); door_right_overlay_interior.setPivot(0.0F, 24.0F, 0.0F); door_right_top_r1 = new ModelPart(this); door_right_top_r1.setPivot(-20.8F, -14.0F, 0.0F); door_right_overlay_interior.addChild(door_right_top_r1); setRotationAngle(door_right_top_r1, 0.0F, 3.1416F, 0.1107F); door_right_top_r1.setTextureOffset(0, -16).addCuboid(-1.1F, -19.0F, 0.0F, 0.0F, 19.0F, 16.0F, 0.0F, false); door_right_bottom_r1 = new ModelPart(this); door_right_bottom_r1.setPivot(0.0F, 0.0F, 0.0F); door_right_overlay_interior.addChild(door_right_bottom_r1); setRotationAngle(door_right_bottom_r1, 0.0F, 3.1416F, 0.0F); door_right_bottom_r1.setTextureOffset(0, 3).addCuboid(19.7F, -14.0F, 0.0F, 0.0F, 12.0F, 16.0F, 0.0F, false); door_left_overlay_exterior = new ModelPart(this); door_left_overlay_exterior.setPivot(0.0F, 24.0F, 0.0F); door_left_top_r2 = new ModelPart(this); door_left_top_r2.setPivot(-20.8F, -14.0F, 0.0F); door_left_overlay_exterior.addChild(door_left_top_r2); setRotationAngle(door_left_top_r2, 0.0F, 0.0F, 0.1107F); door_left_top_r2.setTextureOffset(0, -16).addCuboid(0.1F, -19.0F, 0.0F, 0.0F, 19.0F, 16.0F, 0.0F, false); door_right_overlay_exterior = new ModelPart(this); door_right_overlay_exterior.setPivot(0.0F, 24.0F, 0.0F); door_right_top_r2 = new ModelPart(this); door_right_top_r2.setPivot(-20.8F, -14.0F, 0.0F); door_right_overlay_exterior.addChild(door_right_top_r2); setRotationAngle(door_right_top_r2, 0.0F, 3.1416F, 0.1107F); door_right_top_r2.setTextureOffset(0, -16).addCuboid(-0.1F, -19.0F, 0.0F, 0.0F, 19.0F, 16.0F, 0.0F, false); outer_roof_1 = new ModelPart(this); outer_roof_1.setPivot(0.0F, 24.0F, 0.0F); outer_roof_1_r1 = new ModelPart(this); outer_roof_1_r1.setPivot(-20.0F, -14.0F, 0.0F); outer_roof_1.addChild(outer_roof_1_r1); setRotationAngle(outer_roof_1_r1, 0.0F, 0.0F, 0.1107F); outer_roof_1_r1.setTextureOffset(4, -12).addCuboid(-1.1F, -20.5F, 0.0F, 0.0F, 3.0F, 12.0F, 0.0F, false); outer_roof_2 = new ModelPart(this); outer_roof_2.setPivot(0.0F, 24.0F, 0.0F); outer_roof_2_r1 = new ModelPart(this); outer_roof_2_r1.setPivot(-20.0F, -14.0F, 0.0F); outer_roof_2.addChild(outer_roof_2_r1); setRotationAngle(outer_roof_2_r1, 0.0F, 3.1416F, 0.1107F); outer_roof_2_r1.setTextureOffset(4, -12).addCuboid(1.1F, -20.5F, 0.0F, 0.0F, 3.0F, 12.0F, 0.0F, false); wall_1 = new ModelPart(this); wall_1.setPivot(0.0F, 24.0F, 0.0F); wall_1.setTextureOffset(27, 18).addCuboid(-20.25F, -14.0F, -13.9F, 2.0F, 12.0F, 0.0F, 0.0F, false); upper_wall_1_r1 = new ModelPart(this); upper_wall_1_r1.setPivot(-20.0F, -14.0F, 0.0F); wall_1.addChild(upper_wall_1_r1); setRotationAngle(upper_wall_1_r1, 0.0F, 0.0F, 0.1107F); upper_wall_1_r1.setTextureOffset(27, 18).addCuboid(-0.25F, -1.0F, -13.89F, 2.0F, 1.0F, 0.0F, 0.0F, false); wall_2 = new ModelPart(this); wall_2.setPivot(0.0F, 24.0F, 0.0F); wall_2.setTextureOffset(1, 18).addCuboid(-20.25F, -14.0F, 13.9F, 2.0F, 12.0F, 0.0F, 0.0F, false); upper_wall_2_r1 = new ModelPart(this); upper_wall_2_r1.setPivot(-20.0F, -14.0F, 0.0F); wall_2.addChild(upper_wall_2_r1); setRotationAngle(upper_wall_2_r1, 0.0F, 0.0F, 0.1107F); upper_wall_2_r1.setTextureOffset(1, 18).addCuboid(-0.25F, -1.0F, 13.89F, 2.0F, 1.0F, 0.0F, 0.0F, false); } @Override protected void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, ModelTrainBase.RenderStage renderStage, int light, int position, float doorLeftValue, float doorRightValue) { final float doorLeft = doorLeftValue * DOOR_MAX; final float doorRight = doorRightValue * DOOR_MAX; switch (renderStage) { case INTERIOR: ModelTrainBase.renderOnce(door_left_overlay_interior, matrices, vertexConsumers.getBuffer(MoreRenderLayers.getInterior(DOOR_OVERLAY_TEXTURE_RIGHT)), light, position + doorRight); ModelTrainBase.renderOnce(door_right_overlay_interior, matrices, vertexConsumers.getBuffer(MoreRenderLayers.getInterior(DOOR_OVERLAY_TEXTURE_LEFT)), light, position - doorRight); ModelTrainBase.renderOnceFlipped(door_left_overlay_interior, matrices, vertexConsumers.getBuffer(MoreRenderLayers.getInterior(DOOR_OVERLAY_TEXTURE_RIGHT)), light, position - doorLeft); ModelTrainBase.renderOnceFlipped(door_right_overlay_interior, matrices, vertexConsumers.getBuffer(MoreRenderLayers.getInterior(DOOR_OVERLAY_TEXTURE_LEFT)), light, position + doorLeft); ModelTrainBase.renderMirror(wall_1, matrices, vertexConsumers.getBuffer(MoreRenderLayers.getInterior(DOOR_OVERLAY_TEXTURE_RIGHT)), light, position); ModelTrainBase.renderMirror(wall_2, matrices, vertexConsumers.getBuffer(MoreRenderLayers.getInterior(DOOR_OVERLAY_TEXTURE_LEFT)), light, position); break; case EXTERIOR: ModelTrainBase.renderOnce(door_left_overlay_exterior, matrices, vertexConsumers.getBuffer(MoreRenderLayers.getExterior(DOOR_OVERLAY_TEXTURE_LEFT)), light / 4 * 3, position + doorRight); ModelTrainBase.renderOnce(door_right_overlay_exterior, matrices, vertexConsumers.getBuffer(MoreRenderLayers.getExterior(DOOR_OVERLAY_TEXTURE_RIGHT)), light / 4 * 3, position - doorRight); ModelTrainBase.renderOnceFlipped(door_left_overlay_exterior, matrices, vertexConsumers.getBuffer(MoreRenderLayers.getExterior(DOOR_OVERLAY_TEXTURE_LEFT)), light / 4 * 3, position - doorLeft); ModelTrainBase.renderOnceFlipped(door_right_overlay_exterior, matrices, vertexConsumers.getBuffer(MoreRenderLayers.getExterior(DOOR_OVERLAY_TEXTURE_RIGHT)), light / 4 * 3, position + doorLeft); ModelTrainBase.renderMirror(outer_roof_1, matrices, vertexConsumers.getBuffer(MoreRenderLayers.getExterior(DOOR_OVERLAY_TEXTURE_LEFT)), light, position); ModelTrainBase.renderMirror(outer_roof_2, matrices, vertexConsumers.getBuffer(MoreRenderLayers.getExterior(DOOR_OVERLAY_TEXTURE_RIGHT)), light, position); break; } } } }
52.297406
217
0.741481
d0ea86d546bb7aad299b966fbffe9bce5b2066ef
5,657
package seedu.address.logic.commands; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailureWithoutException; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.address.testutil.TypicalClasses.getAddressBookWithTypicalClasses; import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST; import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND; import static seedu.address.testutil.TypicalIndexes.INDEX_TENTH; import static seedu.address.testutil.TypicalIndexes.INDEX_THIRD; import java.util.List; import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import seedu.address.commons.core.index.Index; import seedu.address.model.AddressBook; import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; import seedu.address.model.tuition.TuitionClass; /** * Contains integration tests (interaction with the Model) and unit tests for DeleteClassCommand. */ public class DeleteClassCommandTest { private Model model = new ModelManager(getAddressBookWithTypicalClasses(), new UserPrefs()); @Test public void execute_deleteOneClass_success() { DeleteClassCommand deleteCommand = new DeleteClassCommand(List.of(INDEX_FIRST)); TuitionClass classToDelete = model.getFilteredTuitionList().get(INDEX_FIRST.getZeroBased()); String expectedMessage = String.format(DeleteClassCommand.MESSAGE_DELETE_CLASSES_SUCCESS, List.of(classToDelete.getName() + "|" + classToDelete.getTimeslot())); ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); expectedModel.deleteTuition(classToDelete); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @Test public void execute_deleteValidWithInvalidClass_failure() { TuitionClass firstClass = model.getTuitionClass(INDEX_FIRST); DeleteClassCommand deleteClassCommand = new DeleteClassCommand(List.of(INDEX_TENTH, INDEX_FIRST)); String expectedMessage = String.format(DeleteClassCommand.MESSAGE_DELETE_CLASSES_SUCCESS, List.of(firstClass.getName() + "|" + firstClass.getTimeslot())) + String.format(DeleteClassCommand.MESSAGE_DELETE_CLASSES_FAILURE, List.of(INDEX_TENTH.getOneBased())); ModelManager expectedModel = new ModelManager(getAddressBookWithTypicalClasses(), new UserPrefs()); assertCommandFailureWithoutException(deleteClassCommand, expectedModel, expectedMessage); } @Test public void execute_outOfBoundsIndex_failure() { Index outOfBoundIndex = Index.fromOneBased(model.getFilteredTuitionList().size() + 1); DeleteClassCommand deleteCommand = new DeleteClassCommand(List.of(outOfBoundIndex)); String expectedMessage = String.format(DeleteClassCommand.MESSAGE_DELETE_CLASSES_FAILURE, List.of(outOfBoundIndex.getOneBased())); assertCommandFailure(deleteCommand, model, expectedMessage); } @Test public void execute_invalidIndex_failure() { Model expectedModel = new ModelManager(new AddressBook(), new UserPrefs()); List<Index> outOfBoundIndex = List.<Index>of(INDEX_THIRD, INDEX_SECOND); DeleteClassCommand deleteClassCommand = new DeleteClassCommand(outOfBoundIndex); String expectedMessage = String.format(DeleteClassCommand.MESSAGE_DELETE_CLASSES_FAILURE, outOfBoundIndex.stream().map(x -> x.getOneBased()).collect(Collectors.toList())); assertCommandFailure(deleteClassCommand, expectedModel, expectedMessage); } @Test public void execute_deleteMultipleClass_success() { List<TuitionClass> classList = List.of(model.getTuitionClass(INDEX_SECOND), model.getTuitionClass(INDEX_FIRST)); List<String> classes = classList.stream() .map(c -> c.getName() + "|" + c.getTimeslot()).collect(Collectors.toList()); DeleteClassCommand deleteCommand = new DeleteClassCommand(List.of(INDEX_SECOND, INDEX_FIRST)); String expectedMessage = String.format(DeleteClassCommand.MESSAGE_DELETE_CLASSES_SUCCESS, classes); ModelManager expectedModel = new ModelManager(getAddressBookWithTypicalClasses(), new UserPrefs()); assertCommandSuccess(deleteCommand, expectedModel, expectedMessage); } @Test public void equals() { DeleteClassCommand firstCommand = new DeleteClassCommand(List.of(INDEX_SECOND, INDEX_FIRST)); DeleteClassCommand secondCommand = new DeleteClassCommand(List.of(INDEX_THIRD, INDEX_SECOND)); // same object -> returns true assertTrue(firstCommand.equals(firstCommand)); // different values -> returns false assertFalse(firstCommand.equals(secondCommand)); //same values and different order -> returns false DeleteClassCommand copy = new DeleteClassCommand(List.of(INDEX_FIRST, INDEX_SECOND)); assertFalse(firstCommand.equals(copy)); // same values and same order -> returns true DeleteClassCommand firstCommandCopy = new DeleteClassCommand(List.of(INDEX_SECOND, INDEX_FIRST)); assertTrue(firstCommand.equals(firstCommandCopy)); // different types -> returns false assertFalse(firstCommand.equals(1)); // null -> returns false assertFalse(firstCommand.equals(null)); } }
46.368852
120
0.754463
5f8c2b981e6c8382e416ce7fda31cc41306a3c8b
3,588
package com.xkcoding.scaffold.config.security.service; import cn.hutool.core.util.ObjectUtil; import com.google.common.collect.Sets; import com.xkcoding.scaffold.common.status.DeleteStatus; import com.xkcoding.scaffold.common.status.LogStatus; import com.xkcoding.scaffold.common.status.Status; import com.xkcoding.scaffold.common.status.UserStatus; import com.xkcoding.scaffold.model.SysMenu; import com.xkcoding.scaffold.model.SysRole; import com.xkcoding.scaffold.model.SysUser; import com.xkcoding.scaffold.model.dto.SysUserDTO; import com.xkcoding.scaffold.service.SysMenuService; import com.xkcoding.scaffold.service.SysRoleService; import com.xkcoding.scaffold.service.SysUserService; import com.xkcoding.scaffold.util.EnumUtil; import com.xkcoding.scaffold.util.LoginLogUtil; import org.modelmapper.ModelMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.DisabledException; import org.springframework.security.authentication.LockedException; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; import java.util.List; /** * <p> * 自定义用户验证 * </p> * * @package: com.xkcoding.scaffold.config.security.service * @description: 自定义用户验证 * @author: yangkai.shen * @date: Created in 2018/8/8 下午3:59 * @copyright: Copyright (c) 2018 * @version: V1.0 * @modified: yangkai.shen */ @Service public class UserDetailsServiceImpl implements UserDetailsService { @Autowired private ModelMapper modelMapper; @Autowired private SysUserService sysUserService; @Autowired private SysRoleService sysRoleService; @Autowired private SysMenuService sysMenuService; /** * 根据登录名查询用户信息,账号异常时保存日志信息 * * @param username 用户名 * @return {@link SysUserDTO} * @throws UsernameNotFoundException 账号不存在 */ @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { // 根据登录名查询用户 SysUser loginUser = sysUserService.getUserByLoginName(username); // 账号不存在 if (ObjectUtil.isNull(loginUser)) { throw new UsernameNotFoundException(Status.USER_NOT_EXIST.getCode() + ""); } // 账号逻辑删除 DeleteStatus deleteStatus = EnumUtil.getStatusByCode(loginUser.getDelFlag(), DeleteStatus.class); if (ObjectUtil.equal(deleteStatus, DeleteStatus.DELETED)) { LoginLogUtil.saveLog(username, Status.USER_DELETED, LogStatus.ERROR); throw new DisabledException(Status.USER_DELETED.getCode() + ""); } // 账号禁用 UserStatus userStatus = EnumUtil.getStatusByCode(loginUser.getStatus(), UserStatus.class); if (ObjectUtil.equal(userStatus, UserStatus.DISABLE)) { LoginLogUtil.saveLog(username, Status.USER_DISABLE, LogStatus.ERROR); throw new LockedException(Status.USER_DISABLE.getCode() + ""); } // 根据用户查询对应角色 List<SysRole> sysRoleList = sysRoleService.listSysRolesByUserId(loginUser.getId()); // 根据角色查询对应菜单 List<SysMenu> sysMenuList = sysMenuService.listSysMenusByRoleList(sysRoleList); // 对象转换 SysUserDTO sysUserDTO = modelMapper.map(loginUser, SysUserDTO.class); sysUserDTO.setRoles(Sets.newHashSet(sysRoleList)); sysUserDTO.setMenus(Sets.newHashSet(sysMenuList)); return sysUserDTO; } }
35.88
105
0.745262
d063d43c279248e412f3a02b2792d555f0cea9ee
6,090
package net.wartori.imm_ptl_surv_adapt.Items; import net.wartori.imm_ptl_surv_adapt.CHelper; import net.wartori.imm_ptl_surv_adapt.Register; import net.minecraft.client.item.TooltipContext; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.wartori.imm_ptl_surv_adapt.RegisterItemGroups; import net.wartori.imm_ptl_surv_adapt.Utils; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; import net.minecraft.util.Hand; import com.mojang.datafixers.util.Pair; import net.minecraft.util.TypedActionResult; import net.minecraft.util.collection.DefaultedList; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; import qouteall.imm_ptl.core.portal.Portal; import qouteall.imm_ptl.core.portal.PortalManipulation; import java.util.List; import java.util.Objects; public class PortalCompleter extends Item { public PortalCompleter(Settings settings) { super(settings); } public static class Data { public static boolean[] portalsToComplete = {false, false, false}; public static NbtCompound serialize() { NbtCompound tag = new NbtCompound(); tag.putIntArray("portalsToComplete", Utils.boolArray2IntArray(portalsToComplete)); return tag; } public static NbtCompound serialize(boolean[] boolArray) { NbtCompound tag = new NbtCompound(); tag.putIntArray("portalsToComplete", Utils.boolArray2IntArray(boolArray)); return tag; } public static void deserialize(NbtCompound tag) { portalsToComplete = Utils.intArray2boolArray(tag.getIntArray("portalsToComplete")); } } @Override public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) { if (!world.isClient()) { Portal portal = Utils.getPortalPlayerPointing(user, false); if (portal != null) { int portalsCompleted = 0; Data.deserialize(user.getStackInHand(hand).getOrCreateNbt()); if (Data.portalsToComplete[0] && PortalManipulation.getPortalClutter(world, portal.getOriginPos(), portal.getNormal().multiply(-1), p -> Objects.equals(p.specificPlayerId, portal.specificPlayerId) && portal.getDiscriminator() != (p.getDiscriminator())).isEmpty()) { Portal portalBack = PortalManipulation.createFlippedPortal(portal, portal.entityType); portalBack.world.spawnEntity(portalBack); Utils.damageIt((ServerPlayerEntity) user, hand); portalsCompleted++; } if (Data.portalsToComplete[1] && PortalManipulation.getPortalClutter(world, portal.getDestPos(), portal.transformLocalVecNonScale(portal.getNormal()), p -> Objects.equals(p.specificPlayerId, portal.specificPlayerId) && portal.getDiscriminator() != (p.getDiscriminator())).isEmpty()) { Portal portalExit = PortalManipulation.createReversePortal(portal, portal.entityType); Portal portalExitBack = PortalManipulation.createFlippedPortal(portalExit, portal.entityType); portalExitBack.world.spawnEntity(portalExitBack); Utils.damageIt((ServerPlayerEntity) user, hand); portalsCompleted++; } if (Data.portalsToComplete[2] && PortalManipulation.getPortalClutter(world, portal.getDestPos(), portal.transformLocalVecNonScale(portal.getNormal().multiply(-1)), p -> Objects.equals(p.specificPlayerId, portal.specificPlayerId) && portal.getDiscriminator() != (p.getDiscriminator())).isEmpty()) { Portal portalExit = PortalManipulation.createReversePortal(portal, portal.entityType); portalExit.world.spawnEntity(portalExit); Utils.damageIt((ServerPlayerEntity) user, hand); portalsCompleted++; } if (portalsCompleted > 0) { return TypedActionResult.success(user.getStackInHand(hand)); } else { return TypedActionResult.fail(user.getStackInHand(hand)); } } } else { Portal portal = Utils.getPortalPlayerPointing(user, true); if (portal == null && user.isSneaking() && hand.equals(Hand.MAIN_HAND)) { CHelper.safeOpenScreenPortalCompleter(user, hand); return TypedActionResult.success(user.getStackInHand(hand)); } } return TypedActionResult.fail(user.getStackInHand(hand)); } @Override public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) { tooltip.add(1, new TranslatableText("tooltip.imm_ptl_surv_adapt.portal_completer_desc")); tooltip.add(2, new TranslatableText("tooltip.imm_ptl_surv_adapt.shift_use_to_configure")); super.appendTooltip(stack, world, tooltip, context); } @Override public void appendStacks(ItemGroup group, DefaultedList<ItemStack> stacks) { if (this.isIn(group) || RegisterItemGroups.IMMERSIVE_PORTALS_SURVIVAL_ADAPTATION_GROUP == group) { for (boolean i : new boolean[]{false, true}) { ItemStack itemStack = new ItemStack(Register.PORTAL_COMPLETER_ITEM); NbtCompound tag = Data.serialize(new boolean[]{true, i, i}); itemStack.setNbt(tag); stacks.add(itemStack); } } } }
47.209302
115
0.637438
9f1185fda1b91bfb09714317992eaecdfc04dc1b
3,401
/* * * * Copyright (c) 2022. - TinyZ. * * 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.struct.spring.support; import java.util.concurrent.TimeUnit; /** * @author TinyZ. * @date 2020-07-22. */ public class StructStoreConfig { /** * set {@link org.struct.core.StructWorker}'s workspace. */ private String workspace = ""; /** * Lazy load struct data before user use it. * * @see StructStore#initialize() */ private boolean lazyLoad = true; /** * Monitor struct file changed event. */ private boolean monitorFileChange = true; /** * Set the scheduled job's initial delay. */ private long scheduleInitialDelay = 10L; /** * Set the scheduled job's delay. */ private long scheduleDelay = 5L; /** * Set schedule job's {@link TimeUnit} */ private TimeUnit scheduleTimeUnit = TimeUnit.SECONDS; /** * When the {@link #lazyLoad} is true, is user should sync wait for {@link StructStore} init done. */ private boolean syncWaitForInit = true; /** * Print {@link StructStoreService}'s banner. */ private boolean banner = true; public String getWorkspace() { return workspace; } public StructStoreConfig setWorkspace(String workspace) { this.workspace = workspace; return this; } public boolean isLazyLoad() { return lazyLoad; } public StructStoreConfig setLazyLoad(boolean lazyLoad) { this.lazyLoad = lazyLoad; return this; } public boolean isMonitorFileChange() { return monitorFileChange; } public StructStoreConfig setMonitorFileChange(boolean monitorFileChange) { this.monitorFileChange = monitorFileChange; return this; } public long getScheduleInitialDelay() { return scheduleInitialDelay; } public StructStoreConfig setScheduleInitialDelay(long scheduleInitialDelay) { this.scheduleInitialDelay = scheduleInitialDelay; return this; } public long getScheduleDelay() { return scheduleDelay; } public StructStoreConfig setScheduleDelay(long scheduleDelay) { this.scheduleDelay = scheduleDelay; return this; } public TimeUnit getScheduleTimeUnit() { return scheduleTimeUnit; } public StructStoreConfig setScheduleTimeUnit(TimeUnit scheduleTimeUnit) { this.scheduleTimeUnit = scheduleTimeUnit; return this; } public boolean isSyncWaitForInit() { return syncWaitForInit; } public void setSyncWaitForInit(boolean syncWaitForInit) { this.syncWaitForInit = syncWaitForInit; } public boolean isBanner() { return banner; } public void setBanner(boolean banner) { this.banner = banner; } }
25.192593
102
0.653337
803e1a5db3d2cd16525caef3e3a7ecb2f27ea36a
1,614
package com.qinweizhao.product.service.impl; import com.qinweizhao.common.core.utils.DateUtils; import com.qinweizhao.product.model.entity.PmsCategoryBrand; import com.qinweizhao.product.mapper.PmsCategoryBrandMapper; import com.qinweizhao.product.service.IPmsCategoryBrandService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; /** * 分类&品牌关联Service业务层处理 * * @author qinweizhao * @date 2022-04-11 */ @Service public class PmsCategoryBrandServiceImpl implements IPmsCategoryBrandService { @Resource private PmsCategoryBrandMapper pmsCategoryBrandMapper; /** * 查询分类&品牌关联列表 * * @param pmsCategoryBrand 分类&品牌关联 * @return 分类&品牌关联 */ @Override public List<PmsCategoryBrand> list(PmsCategoryBrand pmsCategoryBrand) { return pmsCategoryBrandMapper.selectList(pmsCategoryBrand); } /** * 新增分类&品牌关联 * * @param pmsCategoryBrand 分类&品牌关联 * @return 结果 */ @Override public int save(PmsCategoryBrand pmsCategoryBrand) { pmsCategoryBrand.setCreateTime(DateUtils.getNowDate()); return pmsCategoryBrandMapper.insert(pmsCategoryBrand); } /** * 批量删除分类&品牌关联 * * @param ids 需要删除的分类&品牌关联主键 * @return 结果 */ @Override public int removeByIds(Long[] ids) { return pmsCategoryBrandMapper.deleteByIds(ids); } /** * 删除分类&品牌关联信息 * * @param id 分类&品牌关联主键 * @return 结果 */ @Override public int removeById(Long id) { return pmsCategoryBrandMapper.deleteById(id); } }
22.416667
78
0.685254
9f5074787e0fcafc888e05af467816545ea77b85
293
package no.ntnu.dto; /** * Data transfer object (DTO) for submitting changes to user profile data */ public class UserProfileDto { private final String bio; public UserProfileDto(String bio) { this.bio = bio; } public String getBio() { return bio; } }
17.235294
73
0.634812
f832f79d13783eeebbc9274ac8884c11c4127830
5,156
package yuku.filechooser; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Environment; import android.support.v7.app.ActionBar; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.ListView; import android.widget.TextView; import yuku.alkitab.base.ac.base.BaseActivity; import yuku.alkitab.debug.R; import java.io.File; import java.io.FileFilter; import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; public class FileChooserActivity extends BaseActivity { static final String EXTRA_config = "config"; static final String EXTRA_result = "result"; public static Intent createIntent(Context context, FileChooserConfig config) { Intent res = new Intent(context, FileChooserActivity.class); res.putExtra(EXTRA_config, config); return res; } public static FileChooserResult obtainResult(Intent data) { if (data == null) return null; return data.getParcelableExtra(EXTRA_result); } ListView lsFile; FileChooserConfig config; FileAdapter adapter; File cd; @Override public void onCreate(Bundle savedInstanceState) { super.willNeedStoragePermission(); super.onCreate(savedInstanceState); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } config = getIntent().getParcelableExtra(EXTRA_config); Utils.configureTitles(this, config.title, config.subtitle); setContentView(R.layout.filechooser_activity_filechooser); lsFile = (ListView) findViewById(R.id.filechooser_lsFile); lsFile.setAdapter(adapter = new FileAdapter()); lsFile.setOnItemClickListener(lsFile_itemClick); init(); } @Override protected void onNeededPermissionsGranted(final boolean immediatelyGranted) { super.onNeededPermissionsGranted(immediatelyGranted); if (!immediatelyGranted) { init(); } } private AdapterView.OnItemClickListener lsFile_itemClick = (parent, view, position, id) -> { File file = adapter.getItem(position); if (file != null) { if (file.isDirectory()) { cd = file; ls(); } else { FileChooserResult result = new FileChooserResult(); result.currentDir = cd.getAbsolutePath(); result.firstFilename = file.getAbsolutePath(); Intent data = new Intent(); data.putExtra(EXTRA_result, result); setResult(RESULT_OK, data); finish(); } } }; @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { finish(); return true; } return super.onOptionsItemSelected(item); } private void init() { if (config.initialDir != null) { cd = new File(config.initialDir); } else { cd = Environment.getExternalStorageDirectory(); } ls(); } void ls() { File[] files = cd.listFiles(new FileFilter() { Matcher m; @Override public boolean accept(File pathname) { if (config.pattern == null) { return true; } if (pathname.isDirectory()) { return true; } if (m == null) { m = Pattern.compile(config.pattern).matcher(""); } m.reset(pathname.getName()); return m.matches(); } }); if (files == null) { files = new File[0]; } Arrays.sort(files, (a, b) -> { if (a.isDirectory() && !b.isDirectory()) { return -1; } else if (!a.isDirectory() && b.isDirectory()) { return +1; } // both files or both dirs String aname = a.getName(); String bname = b.getName(); // dot-files are later if (aname.startsWith(".") && !bname.startsWith(".")) { return +1; } else if (!aname.startsWith(".") && bname.startsWith(".")) { return -1; } return aname.compareToIgnoreCase(bname); }); adapter.setNewData(files); lsFile.setSelection(0); } class FileAdapter extends BaseAdapter { File[] files; @Override public int getCount() { return (files == null? 0: files.length) + 1; } public void setNewData(File[] files) { this.files = files; notifyDataSetChanged(); } @Override public File getItem(int position) { if (files == null) return null; if (position == 0) return cd.getParentFile(); return files[position - 1]; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { TextView res = (TextView) (convertView != null? convertView: getLayoutInflater().inflate(android.R.layout.simple_list_item_1, parent, false)); if (position == 0) { res.setText(R.string.filechooser_parent_folder); res.setCompoundDrawablesWithIntrinsicBounds(R.drawable.filechooser_up, 0, 0, 0); } else { File file = getItem(position); res.setText(file.getName()); res.setCompoundDrawablesWithIntrinsicBounds(file.isDirectory()? R.drawable.filechooser_folder: R.drawable.filechooser_file, 0, 0, 0); } return res; } } }
24.436019
145
0.683282
500fb5fb24ff6d8595488717145324ea4e395a7a
1,329
package org.archifacts.integration.axon.domain; import static org.axonframework.modelling.command.AggregateLifecycle.apply; import java.util.Map; import java.util.Set; import org.axonframework.commandhandling.CommandHandler; import org.axonframework.commandhandling.CommandMessage; import org.axonframework.eventsourcing.EventSourcingHandler; import org.axonframework.modelling.command.AggregateIdentifier; import org.axonframework.modelling.command.AggregateMember; import org.axonframework.modelling.command.AggregateRoot; @AggregateRoot public class MyAggregateRoot { @AggregateIdentifier private MyAggregateRootId id; @AggregateMember private MyAggregateMember1 myAggregateMember1; @AggregateMember private Map<String, MyAggregateMember2> myAggregateMember2; @AggregateMember private Set<MyAggregateMember3> myAggregateMember3; @AggregateMember @SuppressWarnings("rawtypes") private Map untypedAggregateMemberMap; @AggregateMember @SuppressWarnings("rawtypes") private Set untypedAggregateMemberCollection; @CommandHandler public MyAggregateRoot(final MyCommand1 command) { apply(new MyEvent1(command.getId())); } @EventSourcingHandler public void handle(final MyEvent1 event) { id = event.getId(); } @CommandHandler public void handle(final CommandMessage<MyCommand2> command) { } }
25.075472
75
0.829195
b67e43f3413db40e9718fa2901b48fc3672203dd
1,610
package controller.impl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import agent.AgentLogin; import dbmanagement.impl.DBServiceClass; @RestController public class AgentRestController { @Autowired private DBServiceClass dbService; @RequestMapping(value="/restLogin", method=RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ResponseEntity<agent.AgentInfo> okUser(@RequestBody AgentLogin receivedInfo) { agent.AgentInfo agent = dbService.getAgent(receivedInfo.getId(), receivedInfo.getPassword(), receivedInfo.getKind()); if(agent == null) return new ResponseEntity<>(HttpStatus.NOT_FOUND); else return new ResponseEntity<>(agent, HttpStatus.OK); } @RequestMapping(value="/restAgentInfo", method=RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public agent.AgentInfo returnAgentInfo(@RequestBody AgentLogin receivedInfo) { agent.AgentInfo agent = dbService.findById(receivedInfo.getId()); return agent; } }
38.333333
120
0.798137
9c0023988be85e5c7a24e65520d4d17d18ce1f12
1,085
/* * Copyright © 2017-2020 factcast.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 org.factcast.factus.event; import static org.junit.jupiter.api.Assertions.*; import java.util.Set; import java.util.UUID; import lombok.val; import org.junit.jupiter.api.*; class EventObjectTest { @Test void defaultsToEmptyMap() { val map = new EventObject() { @Override public Set<UUID> aggregateIds() { return null; } }.additionalMetaMap(); assertNotNull(map); assertTrue(map.isEmpty()); } }
27.125
75
0.690323
f482acfc01f8f6e9c0ba244e02d7f08f750005d3
6,893
package de.gsi.dataset.utils; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.temporal.ChronoUnit; import java.util.Collection; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Regression testing for @see Cache * * @author rstein */ public class CacheTests { private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class); @Test public void demoTestCase() { final Cache<String, Integer> cache = Cache.builder().withLimit(10).withTimeout(100, TimeUnit.MILLISECONDS) .build(); String name1 = "Han Solo"; cache.put(name1, 10); assertTrue(isCached(cache, name1), "initial push"); // Wait 1 second try { Thread.sleep(50); } catch (InterruptedException e) { LOGGER.atError().setCause(e).log("sleep"); } assertTrue(isCached(cache, name1), "check after 500 ms"); // Wait another second try { Thread.sleep(200); } catch (InterruptedException e) { LOGGER.atError().setCause(e).log("sleep"); } assertFalse(isCached(cache, name1), "check after 500 ms"); } private boolean isCached(Cache cache, final String KEY) { return cache.getOptional(KEY).isPresent(); } @Test public void testHelperMethods() { // TimeUnit to ChronoUnit conversions for (TimeUnit timeUnit : TimeUnit.values()) { ChronoUnit chronoUnit = Cache.convertToChronoUnit(timeUnit); // timeUnit.toChronoUnit() would be faster but exists only since Java 9 long nanoTimeUnit = timeUnit.toNanos(1); long nanoChrono = chronoUnit.getDuration().getNano() + 1000000000 * chronoUnit.getDuration().getSeconds(); assertEquals(nanoTimeUnit, nanoChrono, "ChronoUnit =" + chronoUnit); } // test clamp(int ... ) routine assertEquals(1, Cache.clamp(1, 3, 0)); assertEquals(2, Cache.clamp(1, 3, 2)); assertEquals(3, Cache.clamp(1, 3, 4)); // test clamp(long ... ) routine assertEquals(1l, Cache.clamp(1l, 3l, 0l)); assertEquals(2l, Cache.clamp(1l, 3l, 2l)); assertEquals(3l, Cache.clamp(1l, 3l, 4l)); } @Test public void testCacheSizeLimit() { Cache<String, Integer> cache = Cache.builder().withLimit(3).build(); assertEquals(3, cache.getLimit()); for (int i = 0; i < 10; i++) { cache.put("test" + i, 10); if (i < cache.getLimit()) { assertEquals(i + 1, cache.getSize()); } assertTrue(cache.getSize() <= 3, "cache size during iteration " + i); } assertEquals(3, cache.getLimit()); final String testString = "testString"; cache.put(testString, 42); assertTrue(isCached(cache, testString), testString + " being cached"); assertEquals(42, cache.get(testString), testString + " being cached"); cache.remove(testString); assertFalse(isCached(cache, testString), testString + " being removed from cache"); cache.clear(); assertEquals(0, cache.size(), "cache size"); cache.put(testString, 42); assertTrue(cache.containsKey(testString), "containsKey"); assertTrue(cache.containsValue(42), "containsValue"); Set<Entry<String, Integer>> entrySet = cache.entrySet(); assertEquals(1, entrySet.size(), "entrySet size"); for (Entry<String, Integer> entry : entrySet) { assertEquals(testString, entry.getKey(), "entrySet - key"); assertEquals(42, entry.getValue(), "entrySet - value"); } Set<String> keySet = cache.keySet(); assertEquals(1, keySet.size(), "keySet size"); for (String key : keySet) { assertEquals(testString, key, "keySet - key"); } Collection<Integer> values = cache.values(); assertEquals(1, values.size(), "values size"); for (Integer value : values) { assertEquals(42, value, "values - value"); } assertEquals(1, cache.size(), "cache size"); cache.clear(); assertEquals(0, cache.size(), "cache size"); assertFalse(isCached(cache, testString), testString + " being removed from cache"); assertTrue(cache.isEmpty(), " cache being empty after clear"); Map<String, Integer> mapToAdd = new ConcurrentHashMap<>(); mapToAdd.put("Test1", 1); mapToAdd.put("Test2", 2); mapToAdd.put("Test3", 3); cache.putAll(mapToAdd); assertEquals(3, cache.size(), "cache size"); } @Test public void testConstructors() { Cache cache1 = new Cache(20); // limit assertEquals(20, cache1.getLimit(), "limit"); Cache cache2 = new Cache(1000, TimeUnit.MILLISECONDS); // time-out assertEquals(1000, cache2.getTimeout(), "time out"); assertEquals(TimeUnit.MILLISECONDS, cache2.getTimeUnit(), "time unit"); Cache cache3 = new Cache(1000, TimeUnit.MILLISECONDS, 20); // time-out && limit assertEquals(20, cache3.getLimit(), "limit"); assertEquals(TimeUnit.MILLISECONDS, cache3.getTimeUnit(), "limit"); assertEquals(1000, cache3.getTimeout(), "limit"); // check exceptions assertThrows(IllegalArgumentException.class, () -> { // negative time out check new Cache(-1, TimeUnit.MILLISECONDS, 20); }); assertThrows(IllegalArgumentException.class, () -> { // null TimeUnit check new Cache(1, null, 20); }); assertThrows(IllegalArgumentException.class, () -> { // limit < 1 check new Cache(2, TimeUnit.MICROSECONDS, 0); }); // check builder exceptions assertThrows(IllegalArgumentException.class, () -> { // negative time out check Cache.builder().withTimeout(-1, TimeUnit.MILLISECONDS).build(); }); assertThrows(IllegalArgumentException.class, () -> { // null TimeUnit check Cache.builder().withTimeout(1, null).build(); }); assertThrows(IllegalArgumentException.class, () -> { // limit < 1 check Cache.builder().withLimit(0).build(); }); // Cache cache4 = Cache.builder().withLimit(20).withTimeout(100, TimeUnit.MILLISECONDS).build(); } }
35.715026
118
0.606122
8c4b91c57923c7c8339985026957beebc93c0f7b
1,502
package uk.gov.pay.products.client.publicapi.model; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) @JsonIgnoreProperties(value={ "params" }) public class Link { private String href; private String method; private String type; @JsonIgnore private String params; public Link() { } public Link( @JsonProperty("href") String href, @JsonProperty("method") String method, @JsonProperty("type") String type) { this.href = href; this.method = method; this.type = type; } public String getHref() { return href; } public void setHref(String href) { this.href = href; } public String getMethod() { return method; } public void setMethod(String method) { this.method = method; } public String getType() { return type; } public void setType(String type) { this.type = type; } @Override public String toString() { return "Link{" + "href='" + href + '\'' + ", method='" + method + '\'' + ", type='" + type + '\'' + '}'; } }
23.107692
61
0.601864
02bd90cdeec65929dbf942cf74a8f899a1e09c86
1,206
package org.eclipse.microprofile.logging; import java.util.ArrayList; import java.util.List; import java.util.function.Supplier; /** * (Mock) Logger used for testing that exposes internals for Tests to interrogate. * * @param <T> The Type of LogEvents the Logger generates. */ public class MockLogger<T extends LogEvent> extends AbstractLogger<T> { private static Level LEVEL; private final List<T> logEvents = new ArrayList<>(); public MockLogger(String name, Supplier<T> supplier) { super(name, supplier); } @Override public void writeLog(Level lvl, T event) { logEvents.add(event); final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); int lineNumber = 0; if (stackTrace.length >= 4) { StackTraceElement elem = stackTrace[4]; lineNumber = elem.getLineNumber(); } System.out.println(String.format("%-5s %s:%d - %s", lvl, getName(), lineNumber, getJsonString(event))); } public static void setLevel(Level lvl) { LEVEL = lvl; } @Override public boolean isLoggable(Level lvl) { return lvl.intValue() >= LEVEL.intValue(); } public List<T> getEvents() { return logEvents; } }
24.612245
107
0.681592
2e726d3c62edc94bdd15fede839b9ebd8db05090
10,202
/* * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH * under one or more contributor license agreements. See the NOTICE file * distributed with this work for additional information regarding copyright * ownership. Camunda licenses this file to you under the Apache License, * Version 2.0; 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.camunda.bpm.model.xml.test; import static org.camunda.bpm.model.xml.test.assertions.ModelAssertions.assertThat; import static org.junit.Assert.fail; import java.util.Collection; import org.camunda.bpm.model.xml.Model; import org.camunda.bpm.model.xml.ModelInstance; import org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl; import org.camunda.bpm.model.xml.impl.util.ModelTypeException; import org.camunda.bpm.model.xml.instance.ModelElementInstance; import org.camunda.bpm.model.xml.test.assertions.AttributeAssert; import org.camunda.bpm.model.xml.test.assertions.ChildElementAssert; import org.camunda.bpm.model.xml.test.assertions.ModelElementTypeAssert; import org.camunda.bpm.model.xml.type.ModelElementType; import org.junit.Test; import org.w3c.dom.DOMException; public abstract class AbstractModelElementInstanceTest { protected class TypeAssumption { public final String namespaceUri; public final ModelElementType extendsType; public final boolean isAbstract; public TypeAssumption(boolean isAbstract) { this(getDefaultNamespace(), isAbstract); } public TypeAssumption(String namespaceUri, boolean isAbstract) { this(namespaceUri, null, isAbstract); } public TypeAssumption(Class<? extends ModelElementInstance> extendsType, boolean isAbstract) { this(getDefaultNamespace(), extendsType, isAbstract); } public TypeAssumption(String namespaceUri, Class<? extends ModelElementInstance> extendsType, boolean isAbstract) { this.namespaceUri = namespaceUri; this.extendsType = model.getType(extendsType); this.isAbstract = isAbstract; } } protected class ChildElementAssumption { public final String namespaceUri; public final ModelElementType childElementType; public final int minOccurs; public final int maxOccurs; public ChildElementAssumption(Class<? extends ModelElementInstance> childElementType) { this(childElementType, 0, -1); } public ChildElementAssumption(String namespaceUri, Class<? extends ModelElementInstance> childElementType) { this(namespaceUri, childElementType, 0, -1); } public ChildElementAssumption(Class<? extends ModelElementInstance> childElementType, int minOccurs) { this(childElementType, minOccurs, -1); } public ChildElementAssumption(String namespaceUri, Class<? extends ModelElementInstance> childElementType, int minOccurs) { this(namespaceUri, childElementType, minOccurs, -1); } public ChildElementAssumption(Class<? extends ModelElementInstance> childElementType, int minOccurs, int maxOccurs) { this(getDefaultNamespace(), childElementType, minOccurs, maxOccurs); } public ChildElementAssumption(String namespaceUri, Class<? extends ModelElementInstance> childElementType, int minOccurs, int maxOccurs) { this.namespaceUri = namespaceUri; this.childElementType = model.getType(childElementType); this.minOccurs = minOccurs; this.maxOccurs = maxOccurs; } } protected class AttributeAssumption { public final String attributeName; public final String namespace; public final boolean isIdAttribute; public final boolean isRequired; public final Object defaultValue; public AttributeAssumption(String attributeName) { this(attributeName, false, false); } public AttributeAssumption(String namespace, String attributeName) { this(namespace, attributeName, false, false); } public AttributeAssumption(String attributeName, boolean isIdAttribute) { this(attributeName, isIdAttribute, false); } public AttributeAssumption(String namespace, String attributeName, boolean isIdAttribute) { this(namespace, attributeName, isIdAttribute, false); } public AttributeAssumption(String attributeName, boolean isIdAttribute, boolean isRequired) { this(attributeName, isIdAttribute, isRequired, null); } public AttributeAssumption(String namespace, String attributeName, boolean isIdAttribute, boolean isRequired) { this(namespace, attributeName, isIdAttribute, isRequired, null); } public AttributeAssumption(String attributeName, boolean isIdAttribute, boolean isRequired, Object defaultValue) { this(null, attributeName, isIdAttribute, isRequired, defaultValue); } public AttributeAssumption(String namespace, String attributeName, boolean isIdAttribute, boolean isRequired, Object defaultValue) { this.attributeName = attributeName; this.namespace = namespace; this.isIdAttribute = isIdAttribute; this.isRequired = isRequired; this.defaultValue = defaultValue; } } public static ModelInstance modelInstance; public static Model model; public static ModelElementType modelElementType; public static void initModelElementType(GetModelElementTypeRule modelElementTypeRule) { modelInstance = modelElementTypeRule.getModelInstance(); model = modelElementTypeRule.getModel(); modelElementType = modelElementTypeRule.getModelElementType(); assertThat(modelInstance).isNotNull(); assertThat(model).isNotNull(); assertThat(modelElementType).isNotNull(); } public abstract String getDefaultNamespace(); public abstract TypeAssumption getTypeAssumption(); public abstract Collection<ChildElementAssumption> getChildElementAssumptions(); public abstract Collection<AttributeAssumption> getAttributesAssumptions(); public ModelElementTypeAssert assertThatType() { return assertThat(modelElementType); } public AttributeAssert assertThatAttribute(String attributeName) { return assertThat(modelElementType.getAttribute(attributeName)); } public ChildElementAssert assertThatChildElement(ModelElementType childElementType) { ModelElementTypeImpl modelElementTypeImpl = (ModelElementTypeImpl) modelElementType; return assertThat(modelElementTypeImpl.getChildElementCollection(childElementType)); } public ModelElementType getType(Class<? extends ModelElementInstance> instanceClass) { return model.getType(instanceClass); } @Test public void testType() { assertThatType().isPartOfModel(model); TypeAssumption assumption = getTypeAssumption(); assertThatType().hasTypeNamespace(assumption.namespaceUri); if (assumption.isAbstract) { assertThatType().isAbstract(); } else { assertThatType().isNotAbstract(); } if (assumption.extendsType == null) { assertThatType().extendsNoType(); } else { assertThatType().extendsType(assumption.extendsType); } if (assumption.isAbstract) { try { modelInstance.newInstance(modelElementType); fail("Element type " + modelElementType.getTypeName() + " is abstract."); } catch (DOMException e) { // expected exception } catch (ModelTypeException e) { // expected exception } catch (Exception e) { fail("Unexpected exception " + e.getMessage()); } } else { ModelElementInstance modelElementInstance = modelInstance.newInstance(modelElementType); assertThat(modelElementInstance).isNotNull(); } } @Test public void testChildElements() { Collection<ChildElementAssumption> childElementAssumptions = getChildElementAssumptions(); if (childElementAssumptions == null) { assertThatType().hasNoChildElements(); } else { assertThat(modelElementType.getChildElementTypes().size()).isEqualTo(childElementAssumptions.size()); for (ChildElementAssumption assumption : childElementAssumptions) { assertThatType().hasChildElements(assumption.childElementType); if (assumption.namespaceUri != null) { assertThat(assumption.childElementType).hasTypeNamespace(assumption.namespaceUri); } assertThatChildElement(assumption.childElementType) .occursMinimal(assumption.minOccurs) .occursMaximal(assumption.maxOccurs); } } } @Test public void testAttributes() { Collection<AttributeAssumption> attributesAssumptions = getAttributesAssumptions(); if (attributesAssumptions == null) { assertThatType().hasNoAttributes(); } else { assertThat(attributesAssumptions).hasSameSizeAs(modelElementType.getAttributes()); for (AttributeAssumption assumption : attributesAssumptions) { assertThatType().hasAttributes(assumption.attributeName); AttributeAssert attributeAssert = assertThatAttribute(assumption.attributeName); attributeAssert.hasOwningElementType(modelElementType); if (assumption.namespace != null) { attributeAssert.hasNamespaceUri(assumption.namespace); } else { attributeAssert.hasNoNamespaceUri(); } if (assumption.isIdAttribute) { attributeAssert.isIdAttribute(); } else { attributeAssert.isNotIdAttribute(); } if (assumption.isRequired) { attributeAssert.isRequired(); } else { attributeAssert.isOptional(); } if (assumption.defaultValue == null) { attributeAssert.hasNoDefaultValue(); } else { attributeAssert.hasDefaultValue(assumption.defaultValue); } } } } }
35.547038
142
0.735346
e069be7b02e2dfa2a95b1bd6e334dff1f0d12996
3,262
package com.o6.controller; import java.security.Principal; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import com.o6.ApplicationConfig; import com.o6.dao.UserEvent; import com.o6.dao.UserEventRepository; import com.o6.security.User; import com.o6.security.UserAuthentication; import com.o6.security.UserRepository; import com.o6.util.CommonUtils; @RestController @RequestMapping(value = "/api/feedback") @ControllerAdvice public class FeedbackController { private static final Logger logger = LoggerFactory.getLogger(FeedbackController.class); /* * TODO Later have independent service for it. */ @Autowired ApplicationConfig appConfig; @Autowired private UserEventRepository eventRepos; @Autowired UserRepository userRepository; @Autowired JavaMailSender mailSender; /* * Convey negative feedback. */ @RequestMapping(value = "/negative", method = RequestMethod.POST) public ResponseEntity<String> registerNegativeFeedback(Principal principal, @RequestBody final String complaintText) { return logFeedback(((UserAuthentication) principal).getDetails(), CommonUtils.NEGATIVE_FEEDBACK, complaintText); } /* * Convey positive or general feedback. */ @RequestMapping(value = "/positiveGeneral", method = RequestMethod.POST) public ResponseEntity<String> registerNegativeOrGeneralFeedback(Principal principal, @RequestBody final String feedbackText) { return logFeedback(((UserAuthentication) principal).getDetails(), CommonUtils.POSITIVE_GENERAL_FEEDBACK, feedbackText); } private ResponseEntity<String> logFeedback(User user, String feedbackType, String message) { eventRepos.save(new UserEvent(user.getId(), feedbackType, message)); sendFeedbackEmail(user.getUsername(), user.getEmail(), feedbackType, message); return new ResponseEntity<String>("Feedback registered", HttpStatus.OK); } private void sendFeedbackEmail(String userName, String userEmail, String feedbackType, String message) { String subject = "Received " + feedbackType + " from " + userName + "<" + userEmail + ">"; CommonUtils.commonExecService().execute(new Runnable() { @Override public void run() { CommonUtils.sendEmail(mailSender, appConfig.senderName, appConfig.senderEmail, appConfig.senderEmail, subject, message, false); } }); } /* * General exception handling */ @ExceptionHandler(Exception.class) public ResponseEntity<String> handleException(Exception e) { logger.error("Exception caught:", e); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); } }
33.979167
123
0.76916
6c60e61f7ec26a19054f31edc3c22f44ee785e3f
8,953
// Copyright (c) 2003-present, Jodd Team (http://jodd.org) // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. package jodd.net; import org.junit.jupiter.api.Test; import java.io.UnsupportedEncodingException; import static jodd.net.URLCoder.encodeFragment; import static jodd.net.URLCoder.encodeHost; import static jodd.net.URLCoder.encodeHttpUrl; import static jodd.net.URLCoder.encodePath; import static jodd.net.URLCoder.encodePathSegment; import static jodd.net.URLCoder.encodePort; import static jodd.net.URLCoder.encodeQuery; import static jodd.net.URLCoder.encodeQueryParam; import static jodd.net.URLCoder.encodeScheme; import static jodd.net.URLCoder.encodeUri; import static jodd.net.URLCoder.encodeUserInfo; import static jodd.net.URLDecoder.decode; import static jodd.net.URLDecoder.decodeQuery; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; class URLCoderTest { @Test void testEncodeScheme() { assertEquals("foobar+-.", encodeScheme("foobar+-.")); assertEquals("foo%20bar", encodeScheme("foo bar")); } @Test void testEncodeUserInfo() { assertEquals("foobar:", encodeUserInfo("foobar:")); assertEquals("foo%20bar", encodeUserInfo("foo bar")); } @Test void testEncodeHost() { assertEquals("foobar", encodeHost("foobar")); assertEquals("foo%20bar", encodeHost("foo bar")); } @Test void testEncodePort() { assertEquals("80", encodePort("80")); } @Test void testEncodePath() { assertEquals("/foo/bar", encodePath("/foo/bar")); assertEquals("/foo%20bar", encodePath("/foo bar")); assertEquals("/Z%C3%BCrich", encodePath("/Z\u00fcrich")); } @Test void testEncodePathSegment() { assertEquals("foobar", encodePathSegment("foobar")); assertEquals("%2Ffoo%2Fbar", encodePathSegment("/foo/bar")); } @Test void testEncodeQuery() { assertEquals("foobar", encodeQuery("foobar")); assertEquals("foo%20bar", encodeQuery("foo bar")); assertEquals("foobar/+", encodeQuery("foobar/+")); assertEquals("T%C5%8Dky%C5%8D", encodeQuery("T\u014dky\u014d")); assertEquals("foo&bar", encodeQuery("foo&bar")); assertEquals("foo=one&bar=two", encodeQuery("foo=one&bar=two")); } @Test void testEncodeQueryParam() { assertEquals("foobar", encodeQueryParam("foobar")); assertEquals("foo%20bar", encodeQueryParam("foo bar")); assertEquals("foobar/+", encodeQuery("foobar/+")); assertEquals("foo%26bar", encodeQueryParam("foo&bar")); assertEquals("foo%3Dbar", encodeQueryParam("foo=bar")); assertEquals("foo@bar", encodeQueryParam("foo@bar")); assertEquals("foo%3Done%26bar%3Dtwo", encodeQueryParam("foo=one&bar=two")); } @Test void testEncodeFragment() { assertEquals("foobar", encodeFragment("foobar")); assertEquals("foo%20bar", encodeFragment("foo bar")); assertEquals("foobar/", encodeFragment("foobar/")); } @Test void testDecode() { assertEquals("", decode("")); assertEquals("foobar", decode("foobar")); assertEquals("foo bar", decode("foo%20bar")); assertEquals("foo+bar", decode("foo%2bbar")); assertEquals("T\u014dky\u014d", decode("T%C5%8Dky%C5%8D")); assertEquals("/Z\u00fcrich", decode("/Z%C3%BCrich")); assertEquals("T\u014dky\u014d", decode("T\u014dky\u014d")); assertEquals("foo+bar", decode("foo+bar")); assertEquals("foo bar", decodeQuery("foo+bar")); } @Test void testEncodeUri() { assertEquals("http://www.ietf.org/rfc/rfc3986.txt", encodeUri("http://www.ietf.org/rfc/rfc3986.txt")); assertEquals("https://www.ietf.org/rfc/rfc3986.txt", encodeUri("https://www.ietf.org/rfc/rfc3986.txt")); assertEquals("http://www.google.com/?q=Z%C3%BCrich", encodeUri("http://www.google.com/?q=Z\u00fcrich")); assertEquals( "http://arjen:[email protected]:80/javase/6/docs/api/java/util/BitSet.html?foo=bar#and(java.util.BitSet)", encodeUri("http://arjen:[email protected]:80/javase/6/docs/api/java/util/BitSet.html?foo=bar#and(java.util.BitSet)")); assertEquals("http://java.sun.com/j2se/1.3/", encodeUri("http://java.sun.com/j2se/1.3/")); assertEquals("docs/guide/collections/designfaq.html#28", encodeUri("docs/guide/collections/designfaq.html#28")); assertEquals("../../../demo/jfc/SwingSet2/src/SwingSet2.java", encodeUri("../../../demo/jfc/SwingSet2/src/SwingSet2.java")); assertEquals("file:///~/calendar", encodeUri("file:///~/calendar")); assertEquals("http://example.com/query=foo@bar", encodeUri("http://example.com/query=foo@bar")); assertEquals("http://example.org?format=json&url=http://another.com?foo=bar", encodeUri("http://example.org?format=json&url=http://another.com?foo=bar")); } @Test void testEncodeHttpUrl() { assertEquals("http://www.ietf.org/rfc/rfc3986.txt", encodeHttpUrl("http://www.ietf.org/rfc/rfc3986.txt")); assertEquals("https://www.ietf.org/rfc/rfc3986.txt", encodeHttpUrl("https://www.ietf.org/rfc/rfc3986.txt")); assertEquals("http://www.google.com/?q=Z%C3%BCrich", encodeHttpUrl("http://www.google.com/?q=Z\u00fcrich")); assertEquals("http://ws.geonames.org/searchJSON?q=T%C5%8Dky%C5%8D&style=FULL&maxRows=300", encodeHttpUrl("http://ws.geonames.org/searchJSON?q=T\u014dky\u014d&style=FULL&maxRows=300")); assertEquals( "http://arjen:[email protected]:80/javase/6/docs/api/java/util/BitSet.html?foo=bar", encodeHttpUrl("http://arjen:[email protected]:80/javase/6/docs/api/java/util/BitSet.html?foo=bar")); assertEquals("http://search.twitter.com/search.atom?q=%23avatar", encodeHttpUrl("http://search.twitter.com/search.atom?q=#avatar")); assertEquals("http://java.sun.com/j2se/1.3/", encodeHttpUrl("http://java.sun.com/j2se/1.3/")); assertEquals("http://example.com/query=foo@bar", encodeHttpUrl("http://example.com/query=foo@bar")); } @Test public void encodeHttpUrlMail() { assertThrows(IllegalArgumentException.class, () -> encodeHttpUrl("mailto:[email protected]")); } @Test void testEncodeUrl() { assertEquals("/aaa", URLCoder.encodeUri("/aaa")); assertEquals("/aaa?", URLCoder.encodeUri("/aaa?")); assertEquals("/aaa?b", URLCoder.encodeUri("/aaa?b")); assertEquals("/aaa?b=", URLCoder.encodeUri("/aaa?b=")); assertEquals("/aaa?b=c", URLCoder.encodeUri("/aaa?b=c")); assertEquals("/aaa?b=%20c", URLCoder.encodeUri("/aaa?b= c")); assertEquals("/aaa?b=%20c&", URLCoder.encodeUri("/aaa?b= c&")); assertEquals("/aaa?b=%20c&dd", URLCoder.encodeUri("/aaa?b= c&dd")); assertEquals("/aaa?b=%20c&dd=", URLCoder.encodeUri("/aaa?b= c&dd=")); assertEquals("/aaa?b=%20%20c&dd==", URLCoder.encodeUri("/aaa?b= c&dd==")); assertEquals("?data=The%20string%20%C3%BC@foo-bar", URLCoder.encodeUri("?data=The string ü@foo-bar")); } @Test void testQuerySimple() throws UnsupportedEncodingException { assertEquals("%C5%BD%C4%8C%C4%86", encodeQueryParam("ŽČĆ")); // utf8 assertEquals("@-._~%2B%20", encodeQueryParam("@-._~+ ")); assertEquals("http://jodd.org/download?param=I%20love%20Jodd+Java", URLCoder.encodeHttpUrl("http://jodd.org/download?param=I love Jodd+Java")); assertEquals("http://jodd.org?param=java&jodd", URLCoder.encodeHttpUrl("http://jodd.org?param=java&jodd")); // this is ambiguous } @Test void testUrlBuilder() { assertEquals("http://jodd.org", URLCoder.build("http://jodd.org").get()); assertEquals("http://jodd.org?param=jodd%26java", URLCoder.build("http://jodd.org").queryParam("param", "jodd&java").get()); assertEquals("http://jodd.org?pa%20ram=jodd%2Bjava", URLCoder.build("http://jodd.org").queryParam("pa ram", "jodd+java").get()); assertEquals("/foo?foo=one&bar=two", URLCoder.build("/foo").queryParam("foo", "one").queryParam("bar", "two").get()); } }
42.43128
145
0.714621
8ae7787879a811f110c6cca88ecfc608dd1a3ab4
2,455
package com.dianping.shield.framework; import com.dianping.agentsdk.framework.AgentInfo; import com.dianping.agentsdk.framework.AgentInterface; import com.dianping.agentsdk.framework.AgentListConfig; import com.dianping.agentsdk.utils.AgentInfoHelper; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; /** * Created by zhi.he on 2017/10/23. */ public abstract class ShieldConfig implements AgentListConfig { public abstract ArrayList<ArrayList<ShieldConfigInfo>> getAgentGroupConfig(); @Override public Map<String, AgentInfo> getAgentInfoList() { ArrayList<ArrayList<ShieldConfigInfo>> shieldConfig = getAgentGroupConfig(); if (shieldConfig == null || shieldConfig.isEmpty()) return null; HashMap<String, AgentInfo> agents = new LinkedHashMap<>(); for (int i = 0; i < shieldConfig.size(); i++) { ArrayList<ShieldConfigInfo> groupList = shieldConfig.get(i); if (groupList == null || groupList.isEmpty()) continue; for (int j = 0; j < groupList.size(); j++) { ShieldConfigInfo shieldConfigInfo = groupList.get(j); try { AgentInfo agentInfo = null; if (shieldConfigInfo.agentClass != null) { agentInfo = AgentInfoHelper.createAgentInfo(shieldConfigInfo.agentClass, i, j, shieldConfig.size(), groupList.size()); } else if (shieldConfigInfo.agentPath != null && !"".equals(shieldConfigInfo.agentPath)) { Class agentClass = Class.forName(shieldConfigInfo.agentPath); agentInfo = AgentInfoHelper.createAgentInfo(agentClass, i, j, shieldConfig.size(), groupList.size()); } if (agentInfo != null) { agentInfo.configPriority = shieldConfigInfo.priority; agentInfo.arguments = shieldConfigInfo.arguments; agents.put(shieldConfigInfo.hostName, agentInfo); } } catch (Exception e) { e.printStackTrace(); continue; } } } return agents; } @Override public Map<String, Class<? extends AgentInterface>> getAgentList() { return null; } }
38.359375
110
0.594705
2239a5bf3dd4a0375724aad5d362332bc2207768
4,246
package de.tbressler.quadratum.utils; import static de.tbressler.quadratum.utils.GameBoardUtils.*; import static java.lang.Math.max; import static java.lang.Math.min; import static java.util.Arrays.sort; /** * Utility class that helps calculating squares. * * @author Tobias Bressler * @version 1.0 */ public class SquareUtils { /* Internal constant for an empty array. */ private static final int[] EMPTY_ARRAY = new int[0]; /* Private constructor. */ private SquareUtils() {} /** * Checks if the given indexes are forming a valid square. * * @param index1 The first index, between 0..63. * @param index2 The second index, between 0..63. * @param index3 The third index, between 0..63. * @param index4 The fourth index, between 0..63. * @return True if the pieces are forming a valid square or false. */ public static boolean isSquare(int index1, int index2, int index3, int index4) { return isSquare(new int[]{index1, index2, index3, index4}); } /** * Checks if the given indexes are forming a valid square. * * @param pieces The array with the 4 indexes of the edges of the square. * @return True if the pieces are forming a valid square or false. */ public static boolean isSquare(int[] pieces) { sort(pieces); int[] possiblePieces = getPossiblePieces(pieces[0], pieces[1]); if (possiblePieces.length == 0) return false; // Check possible pieces with given indexes: return (possiblePieces[0] == pieces[2]) && (possiblePieces[1] == pieces[3]) || (possiblePieces[1] == pieces[2]) && (possiblePieces[0] == pieces[3]); } /** * Returns an array with the two possible pieces that are forming a square with * the two given pieces. If the possible pieces are out of range, an empty array is * returned. * * @param index1 The index of the first piece (must be lower than index2). * @param index2 The index of the second piece (must be greater than index1). * @return An array with the two possible pieces or an empty array. */ public static int[] getPossiblePieces(int index1, int index2) { if (index1 > index2) throw new AssertionError("index1 must be lower than index2!"); // Calculate x and y difference and possible pieces. int dx = difX(index1, index2); int dy = difY(index1, index2); // Check if x and y difference > 0. if ((dx == 0) && (dy == 0)) return EMPTY_ARRAY; // Translate index of first two pieces to coords: int[] piece1 = toCoords(index1); int[] piece2 = toCoords(index2); int[] piece3 = new int[]{piece1[0] - ((dx > 0) ? dy : -dy), piece1[1] + ((dx > 0) ? dx : -dx)}; int[] piece4 = new int[]{piece2[0] - ((dx > 0) ? dy : -dy), piece2[1] + ((dx > 0) ? dx : -dx)}; // Check if pieces are in range: if ((piece3[0] < 0) || (piece3[0] > 7) || (piece3[1] < 0) || (piece3[1] > 7) || (piece4[0] < 0) || (piece4[0] > 7) || (piece4[1] < 0) || (piece4[1] > 7)) return EMPTY_ARRAY; // Calculate index of possible pieces: return new int[]{toIndex(piece3[0], piece3[1]), toIndex(piece4[0], piece4[1])}; } /** * Returns the score for the given square. * * @param pieces The array with the 4 indexes of the edges of the square. * @return The score for the square, between 1..64. */ public static int score(int[] pieces) { return score(pieces[0], pieces[1], pieces[2], pieces[3]); } /** * Returns the score for the given square. * * @param index1 The first index, between 0..63. * @param index2 The second index, between 0..63. * @param index3 The third index, between 0..63. * @param index4 The fourth index, between 0..63. * @return The score for the square, between 1..64. */ public static int score(int index1, int index2, int index3, int index4) { int minIndex = min(min(index1, index2), min(index3, index4)); int maxIndex = max(max(index1, index2), max(index3, index4)); int dx = difY(minIndex, maxIndex) + 1; return dx * dx; } }
36.290598
109
0.60975
74176076356281616e11eb9eadf10e8faf54540f
400
package com.example.domain; // Alt+Shift+S // Animal is an abstract class -> ✘ new -> ✘ instantiate object public abstract class Animal { private int legs; // attribute public Animal(int legs) { // constructor this.legs = legs; } public int getLegs() { // concrete method return legs; } public abstract void eat(); // abstract method public abstract void walk(); // abstract method }
20
63
0.69
4594e3c58f69453f702f3a8d7a1f32be05459999
1,880
/*-***************************************************************************** * Copyright 2018 MrTroble * * 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.github.troblecodings.ctf_server; import java.io.*; import java.net.InetSocketAddress; import java.nio.file.*; import com.sun.net.httpserver.*; /** * @author MrTroble * */ public class FileServer{ private HttpServer server; private byte[] file; /** * */ public FileServer(Path fl,String ctx) { try { file = Files.readAllBytes(fl); } catch (IOException e1) { e1.printStackTrace(); } try { server = HttpServer.create(new InetSocketAddress(333), 100); server.setExecutor(null); } catch (IOException e) { e.printStackTrace(); } HttpHandler handler = exch -> { exch.getResponseHeaders().add("Content-Disposition", "attachment; filename=" + fl.getFileName()); exch.sendResponseHeaders(200, file.length); OutputStream str = exch.getResponseBody(); str.write(file); str.flush(); str.close(); }; server.createContext(ctx).setHandler(handler); server.createContext("/" + ctx.replace("/", "")).setHandler(handler); server.start(); } public void stop() { this.server.stop(0); } }
27.647059
101
0.610638
d7eb5382e6ab4569f686166d4a74df17fc917b73
1,477
package org.wickedsource.coderadar.job.core; import static org.wickedsource.coderadar.factories.entities.EntityFactory.job; import static org.wickedsource.coderadar.factories.entities.EntityFactory.project; import java.util.Date; import org.junit.Assert; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.wickedsource.coderadar.job.scan.commit.ScanCommitsJob; import org.wickedsource.coderadar.project.domain.Project; import org.wickedsource.coderadar.project.domain.ProjectRepository; import org.wickedsource.coderadar.testframework.template.IntegrationTestTemplate; public class JobRepositoryTest extends IntegrationTestTemplate { @Autowired private JobRepository repository; @Autowired private ProjectRepository projectRepository; @Test @DirtiesContext public void findTop1() { Project project = projectRepository.save(project().validProject()); ScanCommitsJob job1 = job().waitingPullJob(); job1.setId(null); job1.setQueuedDate(new Date(System.currentTimeMillis() - 600)); job1.setProject(project); job1 = repository.save(job1); ScanCommitsJob job2 = job().waitingPullJob(); job2.setId(null); job2.setProject(project); repository.save(job2); Job foundJob = repository.findTop1ByProcessingStatusOrderByQueuedDate(ProcessingStatus.WAITING); Assert.assertEquals(job1.getId(), foundJob.getId()); } }
33.568182
100
0.796209
8d4d9756c53280e38edaaa6530df50a8c3af9a0d
3,188
/******************************************************************************** * The contents of this file are subject to the GNU General Public License * * (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html * * * * Software distributed under the License is distributed on an "AS IS" basis, * * without warranty of any kind, either expressed or implied. See the License * * for the specific language governing rights and limitations under the * * License. * * * * This file was originally developed as part of the software suite that * * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * * MIT Press 2005. If you modify the contents of this file, please document and * * mark your changes clearly, for the benefit of others. * ********************************************************************************/ package HackGUI; import javax.swing.*; import java.awt.*; import java.io.*; import javax.swing.text.html.*; import javax.swing.event.*; /** * A frame for viewing HTML files. */ public class HTMLViewFrame extends JFrame { // The scroll pane for this frame private JScrollPane scrollPane; // The editor pane for displaying the HTML file. private JEditorPane ep = new JEditorPane(); /** * Constructs a new HTMLViewFrame for the given HTML file. */ public HTMLViewFrame(String fileName) { setTitle("Help"); ep.setEditable(false); ep.setContentType("text/html"); try { ep.setPage("file:" + fileName); } catch (IOException ioe) { System.err.println("Error while reading file: " + fileName); System.exit(-1); } ep.addHyperlinkListener(new Hyperactive()); scrollPane = new JScrollPane(ep); setBounds(30,44,750,460); setDefaultCloseOperation(1); getContentPane().add(scrollPane, BorderLayout.CENTER); } } // Implements the HTML link properties. class Hyperactive implements HyperlinkListener { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane pane = (JEditorPane) e.getSource(); if (e instanceof HTMLFrameHyperlinkEvent) { HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e; HTMLDocument doc = (HTMLDocument)pane.getDocument(); doc.processHTMLFrameHyperlinkEvent(evt); } else { try { pane.setPage(e.getURL()); } catch (IOException ioe) { System.out.println(ioe.getMessage()); System.exit(0); } } } } }
39.358025
82
0.540464
4ea356cefce4b0d4cccde0e1b1463c5f05cb17ba
634
package com.hpy.RentHouse.order.service; /** * @author: beichenhpy * @Date: 2020/5/3 10:30 */ public interface ConfirmContractService { /** * 租客签合同确认 * @param oid 编号 */ void renterConfirm(String oid); /** * 房东签合同确认 * @param oid 编号 */ void ownerConfirm(String oid); /** * 更新合同路径 * @param contract 合同路径 * @param oid 订单编号 */ void updateRenterContract(String contract,String oid); /** * 更新合同路径 * @param contract 合同路径 * @param oid 订单编号 */ void updateOwnerContract(String contract,String oid); }
18.114286
59
0.550473
481110d2b8991e3b6435b0262bf68a51ff58311b
626
package com.kientpham.sample; import java.util.List; import org.springframework.stereotype.Component; import com.kientpham.baseworkflow.BaseBuilderPrePost; import com.kientpham.baseworkflow.BaseOmnibusDTO; import com.kientpham.baseworkflow.WorkflowException; @Component public class PreBuilder implements BaseBuilderPrePost<TransactionModel,SharedDTO>{ @Override public void execute(List<TransactionModel> transactionList, BaseOmnibusDTO<TransactionModel, SharedDTO> omniBusDTO) throws WorkflowException { transactionList.get(0).setInputValue("1"); omniBusDTO.getSharedDTO().setAnything("anything"); } }
25.04
116
0.821086
4debbde779c52e0a45401aad02ea05f6855029a2
1,043
package io.onedev.server.web.page.project.blob.render.renderers.symbollink; import org.apache.wicket.Component; import io.onedev.server.web.PrioritizedComponentRenderer; import io.onedev.server.web.page.project.blob.render.BlobRenderContext; import io.onedev.server.web.page.project.blob.render.BlobRendererContribution; import io.onedev.server.web.page.project.blob.render.BlobRenderContext.Mode; public class SymbolLinkRendererProvider implements BlobRendererContribution { private static final long serialVersionUID = 1L; @Override public PrioritizedComponentRenderer getRenderer(BlobRenderContext context) { if (context.getMode() == Mode.VIEW && context.getBlobIdent().isSymbolLink()) { return new PrioritizedComponentRenderer() { private static final long serialVersionUID = 1L; @Override public Component render(String componentId) { return new SymbolLinkPanel(componentId, context); } @Override public int getPriority() { return 0; } }; } else { return null; } } }
27.447368
80
0.763183
558f71ae0157aa9899ad668b4cf7b1bbb52d7fef
754
package hu.frontrider.gearcraft.events; import hu.frontrider.gearcraft.items.StaffOfTheGhost; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @Mod.EventBusSubscriber public class EntityRightClick { @SubscribeEvent public static void entityRightClick(PlayerInteractEvent.EntityInteract event) { final EntityPlayer player = event.getEntityPlayer(); final Item item = event.getItemStack().getItem(); if (item instanceof StaffOfTheGhost) { player.startRiding(event.getTarget(), true); } } }
34.272727
83
0.767905
a269d070c8ad10d0300458161df79bf98350a4fa
787
package es.amplia.oda.comms.mqtt; import es.amplia.oda.comms.mqtt.api.MqttClientFactory; import es.amplia.oda.comms.mqtt.paho.MqttPahoClientFactory; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; public class Activator implements BundleActivator { private ServiceRegistration<MqttClientFactory> mqttClientFactoryServiceRegistration; @Override public void start(BundleContext bundleContext) { mqttClientFactoryServiceRegistration = bundleContext.registerService(MqttClientFactory.class, new MqttPahoClientFactory(), null); } @Override public void stop(BundleContext bundleContext) { mqttClientFactoryServiceRegistration.unregister(); } }
31.48
106
0.78526
73d57083a726c4bec5a632f7ae599c108559f3c2
274
package eu.nyerel.panda.agent; import java.lang.instrument.Instrumentation; /** * @author Rastislav Papp ([email protected]) */ public class Agent { public static void premain(String args, Instrumentation inst) { new Bootstrap(inst).init(); } }
18.266667
67
0.70073
6b6f431f488c8f659baafd26637b657665250096
2,506
package com.gofish.sentiment.newslinker; import io.vertx.core.Future; import io.vertx.core.eventbus.MessageConsumer; import io.vertx.core.json.JsonObject; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; import io.vertx.rx.java.ObservableFuture; import io.vertx.rx.java.RxHelper; import io.vertx.rxjava.core.AbstractVerticle; import io.vertx.rxjava.servicediscovery.ServiceDiscovery; import io.vertx.rxjava.servicediscovery.types.EventBusService; import io.vertx.servicediscovery.Record; import io.vertx.serviceproxy.ProxyHelper; import java.util.Optional; /** * @author Luke Herron */ public class NewsLinkerVerticle extends AbstractVerticle { private static final Logger LOG = LoggerFactory.getLogger(NewsLinkerVerticle.class); private MessageConsumer<JsonObject> messageConsumer; private ServiceDiscovery serviceDiscovery; private Record record; @Override public void start(Future<Void> startFuture) throws Exception { LOG.info("Bringing up NewsLinkerVerticle"); JsonObject config = Optional.ofNullable(config()) .orElseThrow(() -> new RuntimeException("Could not load linker verticle configuration")); com.gofish.sentiment.newslinker.rxjava.NewsLinkerService newsLinkerService = com.gofish.sentiment.newslinker.rxjava.NewsLinkerService.create(vertx, config); messageConsumer = ProxyHelper.registerService(NewsLinkerService.class, vertx.getDelegate(), newsLinkerService.getDelegate(), NewsLinkerService.ADDRESS); serviceDiscovery = ServiceDiscovery.create(vertx, serviceDiscovery -> { LOG.info("Service Discovery intialised"); record = EventBusService.createRecord(NewsLinkerService.NAME, NewsLinkerService.ADDRESS, NewsLinkerService.class.getName()); serviceDiscovery.rxPublish(record) .subscribe(r -> startFuture.complete(), startFuture::fail); }); } @Override public void stop(Future<Void> stopFuture) throws Exception { ObservableFuture<Void> messageConsumerObservable = new ObservableFuture<>(); serviceDiscovery.rxUnpublish(record.getRegistration()) .flatMapObservable(v -> { messageConsumer.unregister(messageConsumerObservable.toHandler()); return messageConsumerObservable; }) .doOnNext(v -> serviceDiscovery.close()) .subscribe(RxHelper.toSubscriber(stopFuture)); } }
41.766667
164
0.730646
1022e98a19af6d18082735edef354ad2bf0471ec
10,146
/* * 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.commons.math.analysis.polynomials; // commons-math import org.apache.commons.math.MathException; import org.apache.commons.math.TestUtils; // junit import junit.framework.TestCase; /** * Tests the PolynomialFunction implementation of a UnivariateRealFunction. * * @version $Revision$ * @author Matt Cliff <[email protected]> */ public final class PolynomialFunctionTest extends TestCase { /** Error tolerance for tests */ protected double tolerance = 1.0e-12; /** * tests the value of a constant polynomial. * * <p>value of this is 2.5 everywhere.</p> */ public void testConstants() throws MathException { double[] c = { 2.5 }; PolynomialFunction f = new PolynomialFunction( c ); // verify that we are equal to c[0] at several (nonsymmetric) places assertEquals( f.value( 0.0), c[0], tolerance ); assertEquals( f.value( -1.0), c[0], tolerance ); assertEquals( f.value( -123.5), c[0], tolerance ); assertEquals( f.value( 3.0), c[0], tolerance ); assertEquals( f.value( 456.89), c[0], tolerance ); assertEquals(f.degree(), 0); assertEquals(f.derivative().value(0), 0, tolerance); assertEquals(f.polynomialDerivative().derivative().value(0), 0, tolerance); } /** * tests the value of a linear polynomial. * * <p>This will test the function f(x) = 3*x - 1.5</p> * <p>This will have the values * <tt>f(0.0) = -1.5, f(-1.0) = -4.5, f(-2.5) = -9.0, * f(0.5) = 0.0, f(1.5) = 3.0</tt> and <tt>f(3.0) = 7.5</tt> * </p> */ public void testLinear() throws MathException { double[] c = { -1.5, 3.0 }; PolynomialFunction f = new PolynomialFunction( c ); // verify that we are equal to c[0] when x=0 assertEquals( f.value( 0.0), c[0], tolerance ); // now check a few other places assertEquals( -4.5, f.value( -1.0), tolerance ); assertEquals( -9.0, f.value( -2.5), tolerance ); assertEquals( 0.0, f.value( 0.5), tolerance ); assertEquals( 3.0, f.value( 1.5), tolerance ); assertEquals( 7.5, f.value( 3.0), tolerance ); assertEquals(f.degree(), 1); assertEquals(f.polynomialDerivative().derivative().value(0), 0, tolerance); } /** * Tests a second order polynomial. * <p> This will test the function f(x) = 2x^2 - 3x -2 = (2x+1)(x-2)</p> * */ public void testQuadratic() { double[] c = { -2.0, -3.0, 2.0 }; PolynomialFunction f = new PolynomialFunction( c ); // verify that we are equal to c[0] when x=0 assertEquals( f.value( 0.0), c[0], tolerance ); // now check a few other places assertEquals( 0.0, f.value( -0.5), tolerance ); assertEquals( 0.0, f.value( 2.0), tolerance ); assertEquals( -2.0, f.value( 1.5), tolerance ); assertEquals( 7.0, f.value( -1.5), tolerance ); assertEquals( 265.5312, f.value( 12.34), tolerance ); } /** * This will test the quintic function * f(x) = x^2(x-5)(x+3)(x-1) = x^5 - 3x^4 -13x^3 + 15x^2</p> * */ public void testQuintic() { double[] c = { 0.0, 0.0, 15.0, -13.0, -3.0, 1.0 }; PolynomialFunction f = new PolynomialFunction( c ); // verify that we are equal to c[0] when x=0 assertEquals( f.value( 0.0), c[0], tolerance ); // now check a few other places assertEquals( 0.0, f.value( 5.0), tolerance ); assertEquals( 0.0, f.value( 1.0), tolerance ); assertEquals( 0.0, f.value( -3.0), tolerance ); assertEquals( 54.84375, f.value( -1.5), tolerance ); assertEquals( -8.06637, f.value( 1.3), tolerance ); assertEquals(f.degree(), 5); } /** * tests the firstDerivative function by comparison * * <p>This will test the functions * <tt>f(x) = x^3 - 2x^2 + 6x + 3, g(x) = 3x^2 - 4x + 6</tt> * and <tt>h(x) = 6x - 4</tt> */ public void testfirstDerivativeComparison() throws MathException { double[] f_coeff = { 3.0, 6.0, -2.0, 1.0 }; double[] g_coeff = { 6.0, -4.0, 3.0 }; double[] h_coeff = { -4.0, 6.0 }; PolynomialFunction f = new PolynomialFunction( f_coeff ); PolynomialFunction g = new PolynomialFunction( g_coeff ); PolynomialFunction h = new PolynomialFunction( h_coeff ); // compare f' = g assertEquals( f.derivative().value(0.0), g.value(0.0), tolerance ); assertEquals( f.derivative().value(1.0), g.value(1.0), tolerance ); assertEquals( f.derivative().value(100.0), g.value(100.0), tolerance ); assertEquals( f.derivative().value(4.1), g.value(4.1), tolerance ); assertEquals( f.derivative().value(-3.25), g.value(-3.25), tolerance ); // compare g' = h assertEquals( g.derivative().value(Math.PI), h.value(Math.PI), tolerance ); assertEquals( g.derivative().value(Math.E), h.value(Math.E), tolerance ); } public void testString() { PolynomialFunction p = new PolynomialFunction(new double[] { -5.0, 3.0, 1.0 }); checkPolynomial(p, "-5.0 + 3.0 x + x^2"); checkPolynomial(new PolynomialFunction(new double[] { 0.0, -2.0, 3.0 }), "-2.0 x + 3.0 x^2"); checkPolynomial(new PolynomialFunction(new double[] { 1.0, -2.0, 3.0 }), "1.0 - 2.0 x + 3.0 x^2"); checkPolynomial(new PolynomialFunction(new double[] { 0.0, 2.0, 3.0 }), "2.0 x + 3.0 x^2"); checkPolynomial(new PolynomialFunction(new double[] { 1.0, 2.0, 3.0 }), "1.0 + 2.0 x + 3.0 x^2"); checkPolynomial(new PolynomialFunction(new double[] { 1.0, 0.0, 3.0 }), "1.0 + 3.0 x^2"); checkPolynomial(new PolynomialFunction(new double[] { 0.0 }), "0"); } public void testAddition() { PolynomialFunction p1 = new PolynomialFunction(new double[] { -2.0, 1.0 }); PolynomialFunction p2 = new PolynomialFunction(new double[] { 2.0, -1.0, 0.0 }); checkNullPolynomial(p1.add(p2)); p2 = p1.add(p1); checkPolynomial(p2, "-4.0 + 2.0 x"); p1 = new PolynomialFunction(new double[] { 1.0, -4.0, 2.0 }); p2 = new PolynomialFunction(new double[] { -1.0, 3.0, -2.0 }); p1 = p1.add(p2); assertEquals(1, p1.degree()); checkPolynomial(p1, "-x"); } public void testSubtraction() { PolynomialFunction p1 = new PolynomialFunction(new double[] { -2.0, 1.0 }); checkNullPolynomial(p1.subtract(p1)); PolynomialFunction p2 = new PolynomialFunction(new double[] { -2.0, 6.0 }); p2 = p2.subtract(p1); checkPolynomial(p2, "5.0 x"); p1 = new PolynomialFunction(new double[] { 1.0, -4.0, 2.0 }); p2 = new PolynomialFunction(new double[] { -1.0, 3.0, 2.0 }); p1 = p1.subtract(p2); assertEquals(1, p1.degree()); checkPolynomial(p1, "2.0 - 7.0 x"); } public void testMultiplication() { PolynomialFunction p1 = new PolynomialFunction(new double[] { -3.0, 2.0 }); PolynomialFunction p2 = new PolynomialFunction(new double[] { 3.0, 2.0, 1.0 }); checkPolynomial(p1.multiply(p2), "-9.0 + x^2 + 2.0 x^3"); p1 = new PolynomialFunction(new double[] { 0.0, 1.0 }); p2 = p1; for (int i = 2; i < 10; ++i) { p2 = p2.multiply(p1); checkPolynomial(p2, "x^" + i); } } public void testSerial() { PolynomialFunction p2 = new PolynomialFunction(new double[] { 3.0, 2.0, 1.0 }); assertEquals(p2, TestUtils.serializeAndRecover(p2)); } /** * tests the firstDerivative function by comparison * * <p>This will test the functions * <tt>f(x) = x^3 - 2x^2 + 6x + 3, g(x) = 3x^2 - 4x + 6</tt> * and <tt>h(x) = 6x - 4</tt> */ public void testMath341() throws MathException { double[] f_coeff = { 3.0, 6.0, -2.0, 1.0 }; double[] g_coeff = { 6.0, -4.0, 3.0 }; double[] h_coeff = { -4.0, 6.0 }; PolynomialFunction f = new PolynomialFunction( f_coeff ); PolynomialFunction g = new PolynomialFunction( g_coeff ); PolynomialFunction h = new PolynomialFunction( h_coeff ); // compare f' = g assertEquals( f.derivative().value(0.0), g.value(0.0), tolerance ); assertEquals( f.derivative().value(1.0), g.value(1.0), tolerance ); assertEquals( f.derivative().value(100.0), g.value(100.0), tolerance ); assertEquals( f.derivative().value(4.1), g.value(4.1), tolerance ); assertEquals( f.derivative().value(-3.25), g.value(-3.25), tolerance ); // compare g' = h assertEquals( g.derivative().value(Math.PI), h.value(Math.PI), tolerance ); assertEquals( g.derivative().value(Math.E), h.value(Math.E), tolerance ); } public void checkPolynomial(PolynomialFunction p, String reference) { assertEquals(reference, p.toString()); } private void checkNullPolynomial(PolynomialFunction p) { for (double coefficient : p.getCoefficients()) { assertEquals(0.0, coefficient, 1.0e-15); } } }
37.164835
88
0.580919
46b09fca6291655f8e62cedc4229d6c1ae46b7aa
6,266
/* * * Copyright (c) Microsoft. All rights reserved. * Licensed under the MIT license. See LICENSE file in the project root for full license information. * */ package com.microsoft.azure.sdk.iot.provisioning.security; import com.microsoft.azure.sdk.iot.provisioning.security.exceptions.SecurityProviderException; import javax.net.ssl.*; import java.io.IOException; import java.security.*; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Collection; import java.util.UUID; public abstract class SecurityProviderX509 extends SecurityProvider { private static final String ALIAS_CERT_ALIAS = "ALIAS_CERT"; abstract public String getClientCertificateCommonName(); abstract public X509Certificate getClientCertificate(); abstract public Key getClientPrivateKey(); abstract public Collection<X509Certificate> getIntermediateCertificatesChain(); @Override public String getRegistrationId() throws SecurityProviderException { //SRS_SecurityClientX509_25_001: [ This method shall retrieve the commonName of the client certificate and return as registration Id. ] return this.getClientCertificateCommonName(); } @Override public SSLContext getSSLContext() throws SecurityProviderException { try { //SRS_SecurityClientX509_25_002: [ This method shall generate the SSL context. ] return this.generateSSLContext(this.getClientCertificate(), this.getClientPrivateKey(), this.getIntermediateCertificatesChain()); } catch (NoSuchProviderException | UnrecoverableKeyException | NoSuchAlgorithmException | KeyStoreException | KeyManagementException | IOException | CertificateException e) { //SRS_SecurityClientX509_25_003: [ This method shall throw SecurityProviderException chained with the exception thrown from underlying API calls to SSL library. ] throw new SecurityProviderException(e); } } private TrustManager getDefaultX509TrustManager(KeyStore keyStore) throws NoSuchAlgorithmException, KeyStoreException, SecurityProviderException { // obtain X509 trust manager TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(keyStore); for (TrustManager trustManager : trustManagerFactory.getTrustManagers()) { if (trustManager instanceof X509TrustManager) { return trustManager; } } //SRS_SecurityClientX509_25_004: [ This method shall throw SecurityProviderException if X509 Trust Manager is not found. ] throw new SecurityProviderException("Could not retrieve X509 trust manager"); } private KeyManager getDefaultX509KeyManager(KeyStore keyStore, String password) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, SecurityProviderException { // create key manager factory and obtain x509 key manager KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(keyStore, password.toCharArray()); for (KeyManager keyManager : keyManagerFactory.getKeyManagers()) { if (keyManager instanceof X509KeyManager) { return keyManager; } } //SRS_SecurityClientX509_25_005: [ This method shall throw SecurityProviderException if X509 Key Manager is not found. ] throw new SecurityProviderException("Could not retrieve X509 Key Manager"); } private SSLContext generateSSLContext(X509Certificate leafCertificate, Key leafPrivateKey, Collection<X509Certificate> signerCertificates) throws NoSuchProviderException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException, CertificateException, SecurityProviderException { if (leafCertificate == null || leafPrivateKey == null || signerCertificates == null) { //SRS_SecurityClientX509_25_006: [ This method shall throw IllegalArgumentException if input parameters are null. ] throw new IllegalArgumentException("cert or private key cannot be null"); } //SRS_SecurityClientX509_25_007: [ This method shall use random UUID as a password for keystore. ] String password = UUID.randomUUID().toString(); //SRS_SecurityClientX509_25_008: [ This method shall create a TLSv1.2 instance. ] SSLContext sslContext = SSLContext.getInstance(DEFAULT_TLS_PROTOCOL); // Load Trusted certs to keystore and retrieve it. //SRS_SecurityClientX509_25_009: [ This method shall retrieve the keystore loaded with trusted certs. ] KeyStore keyStore = this.getKeyStoreWithTrustedCerts(); if (keyStore == null) { throw new SecurityProviderException("Key store with trusted certs cannot be null"); } // Load Alias cert and private key to key store int noOfCerts = signerCertificates.size() + 1; X509Certificate[] certs = new X509Certificate[noOfCerts]; int i = 0; certs[i++] = leafCertificate; // Load the chain of signer cert to keystore for (X509Certificate c : signerCertificates) { certs[i++] = c; } //SRS_SecurityClientX509_25_010: [ This method shall load all the provided X509 certs (leaf with both public certificate and private key, // intermediate certificates(if any) to the Key store. ] keyStore.setKeyEntry(ALIAS_CERT_ALIAS, leafPrivateKey, password.toCharArray(), certs); //SRS_SecurityClientX509_25_011: [ This method shall initialize the ssl context with X509KeyManager and X509TrustManager for the keystore. ] sslContext.init(new KeyManager[] {this.getDefaultX509KeyManager(keyStore, password)}, new TrustManager[] {this.getDefaultX509TrustManager(keyStore)}, new SecureRandom()); //SRS_SecurityClientX509_25_012: [ This method shall return the ssl context created as above to the caller. ] return sslContext; } }
48.2
331
0.728375
ddf9a76e3bc901fd7978e3ac51e327c200c21b47
1,173
package com.telran.qa25.objects; public class User { private String firstName; private String secondName; private String email; private String password; public String getFirstName() { return firstName; } public User setFirstName(String firstName) { this.firstName = firstName; return this; } public String getSecondName() { return secondName; } public User setSecondName(String secondName) { this.secondName = secondName; return this; } public String getEmail() { return email; } public User setEmail(String email) { this.email = email; return this; } public String getPassword() { return password; } public User setPassword(String password) { this.password = password; return this; } @Override public String toString() { return "User{" + "firstName='" + firstName + '\'' + ", secondName='" + secondName + '\'' + ", email='" + email + '\'' + ", password='" + password + '\'' + '}'; } }
21.327273
54
0.542199
712a73ea81d0e2ec94a82d7bd9cea5e0615dd0e4
13,087
/* * 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.inlong.manager.service.core.impl; import com.google.common.util.concurrent.ThreadFactoryBuilder; import org.apache.inlong.manager.common.enums.ErrorCodeEnum; import org.apache.inlong.manager.common.enums.GroupMode; import org.apache.inlong.manager.common.enums.GroupOperateType; import org.apache.inlong.manager.common.enums.GroupStatus; import org.apache.inlong.manager.common.exceptions.WorkflowListenerException; import org.apache.inlong.manager.common.pojo.group.InlongGroupInfo; import org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo; import org.apache.inlong.manager.common.pojo.stream.StreamBriefResponse; import org.apache.inlong.manager.common.pojo.workflow.WorkflowResult; import org.apache.inlong.manager.common.pojo.workflow.form.LightGroupResourceProcessForm; import org.apache.inlong.manager.common.pojo.workflow.form.NewGroupProcessForm; import org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm; import org.apache.inlong.manager.service.core.InlongGroupService; import org.apache.inlong.manager.service.core.InlongStreamService; import org.apache.inlong.manager.service.workflow.ProcessName; import org.apache.inlong.manager.service.workflow.WorkflowService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy; import java.util.concurrent.TimeUnit; /** * Operation related to inlong group process */ @Service public class InlongGroupProcessOperation { private static final Logger LOGGER = LoggerFactory.getLogger(InlongGroupProcessOperation.class); private final ExecutorService executorService = new ThreadPoolExecutor( 20, 40, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("inlong-group-process-%s").build(), new CallerRunsPolicy()); @Autowired private InlongGroupService groupService; @Autowired private WorkflowService workflowService; @Autowired private InlongStreamService streamService; /** * Allocate resource application groups for access services and initiate an approval process * * @param groupId Inlong group id * @param operator Operator name * @return Workflow result */ public WorkflowResult startProcess(String groupId, String operator) { LOGGER.info("begin to start approve process, groupId = {}, operator = {}", groupId, operator); groupService.updateStatus(groupId, GroupStatus.TO_BE_APPROVAL.getCode(), operator); // Initiate the approval process NewGroupProcessForm form = genNewGroupProcessForm(groupId); return workflowService.start(ProcessName.NEW_GROUP_PROCESS, operator, form); } /** * Suspend resource application group in an asynchronous way, * stop source and sort task related to application group asynchronously, * persist the application status if necessary. * * @return groupId */ public String suspendProcessAsync(String groupId, String operator) { LOGGER.info("begin to suspend process asynchronously, groupId = {}, operator = {}", groupId, operator); groupService.updateStatus(groupId, GroupStatus.SUSPENDING.getCode(), operator); InlongGroupInfo groupInfo = groupService.get(groupId); GroupMode mode = GroupMode.parseGroupMode(groupInfo); switch (mode) { case NORMAL: UpdateGroupProcessForm form = genUpdateGroupProcessForm(groupInfo, GroupOperateType.SUSPEND); executorService.execute(() -> workflowService.start(ProcessName.SUSPEND_GROUP_PROCESS, operator, form)); break; case LIGHT: LightGroupResourceProcessForm lightForm = genLightGroupProcessForm(groupInfo, GroupOperateType.SUSPEND); executorService.execute( () -> workflowService.start(ProcessName.SUSPEND_LIGHT_GROUP_PROCESS, operator, lightForm)); break; default: throw new WorkflowListenerException(ErrorCodeEnum.GROUP_MODE_UNSUPPORTED.getMessage()); } return groupId; } /** * Suspend resource application group which is started up successfully, * stop source and sort task related to application group asynchronously, * persist the application status if necessary. * * @return Workflow result */ public WorkflowResult suspendProcess(String groupId, String operator) { LOGGER.info("begin to suspend process, groupId = {}, operator = {}", groupId, operator); groupService.updateStatus(groupId, GroupStatus.SUSPENDING.getCode(), operator); InlongGroupInfo groupInfo = groupService.get(groupId); GroupMode mode = GroupMode.parseGroupMode(groupInfo); WorkflowResult result; switch (mode) { case NORMAL: UpdateGroupProcessForm form = genUpdateGroupProcessForm(groupInfo, GroupOperateType.SUSPEND); result = workflowService.start(ProcessName.SUSPEND_GROUP_PROCESS, operator, form); break; case LIGHT: LightGroupResourceProcessForm lightForm = genLightGroupProcessForm(groupInfo, GroupOperateType.SUSPEND); result = workflowService.start(ProcessName.SUSPEND_LIGHT_GROUP_PROCESS, operator, lightForm); break; default: throw new WorkflowListenerException(ErrorCodeEnum.GROUP_MODE_UNSUPPORTED.getMessage()); } return result; } /** * Restart resource application group in an asynchronous way, * starting from the last persist snapshot. * * @return Workflow result */ public String restartProcessAsync(String groupId, String operator) { LOGGER.info("begin to restart process asynchronously, groupId = {}, operator = {}", groupId, operator); groupService.updateStatus(groupId, GroupStatus.RESTARTING.getCode(), operator); InlongGroupInfo groupInfo = groupService.get(groupId); GroupMode mode = GroupMode.parseGroupMode(groupInfo); switch (mode) { case NORMAL: UpdateGroupProcessForm form = genUpdateGroupProcessForm(groupInfo, GroupOperateType.RESTART); executorService.execute(() -> workflowService.start(ProcessName.RESTART_GROUP_PROCESS, operator, form)); break; case LIGHT: LightGroupResourceProcessForm lightForm = genLightGroupProcessForm(groupInfo, GroupOperateType.RESTART); executorService.execute( () -> workflowService.start(ProcessName.RESTART_LIGHT_GROUP_PROCESS, operator, lightForm)); break; default: throw new WorkflowListenerException(ErrorCodeEnum.GROUP_MODE_UNSUPPORTED.getMessage()); } return groupId; } /** * Restart resource application group which is suspended successfully, * starting from the last persist snapshot. * * @return Workflow result */ public WorkflowResult restartProcess(String groupId, String operator) { LOGGER.info("begin to restart process, groupId = {}, operator = {}", groupId, operator); groupService.updateStatus(groupId, GroupStatus.RESTARTING.getCode(), operator); InlongGroupInfo groupInfo = groupService.get(groupId); GroupMode mode = GroupMode.parseGroupMode(groupInfo); WorkflowResult result; switch (mode) { case NORMAL: UpdateGroupProcessForm form = genUpdateGroupProcessForm(groupInfo, GroupOperateType.RESTART); result = workflowService.start(ProcessName.RESTART_GROUP_PROCESS, operator, form); break; case LIGHT: LightGroupResourceProcessForm lightForm = genLightGroupProcessForm(groupInfo, GroupOperateType.RESTART); result = workflowService.start(ProcessName.RESTART_LIGHT_GROUP_PROCESS, operator, lightForm); break; default: throw new WorkflowListenerException(ErrorCodeEnum.GROUP_MODE_UNSUPPORTED.getMessage()); } return result; } /** * Delete resource application group logically and delete related resource in an */ public String deleteProcessAsync(String groupId, String operator) { LOGGER.info("begin to delete process asynchronously, groupId = {}, operator = {}", groupId, operator); executorService.execute(() -> { try { invokeDeleteProcess(groupId, operator); } catch (Exception ex) { LOGGER.error("exception while delete process, groupId = {}, operator = {}", groupId, operator, ex); throw ex; } groupService.delete(groupId, operator); }); return groupId; } /** * Delete resource application group logically and delete related resource in an asynchronous way */ public boolean deleteProcess(String groupId, String operator) { LOGGER.info("begin to delete process, groupId = {}, operator = {}", groupId, operator); try { invokeDeleteProcess(groupId, operator); } catch (Exception ex) { LOGGER.error("exception while delete process, groupId = {}, operator = {}", groupId, operator, ex); throw ex; } return groupService.delete(groupId, operator); } private void invokeDeleteProcess(String groupId, String operator) { InlongGroupInfo groupInfo = groupService.get(groupId); GroupMode mode = GroupMode.parseGroupMode(groupInfo); switch (mode) { case NORMAL: UpdateGroupProcessForm form = genUpdateGroupProcessForm(groupInfo, GroupOperateType.DELETE); workflowService.start(ProcessName.DELETE_GROUP_PROCESS, operator, form); break; case LIGHT: LightGroupResourceProcessForm lightForm = genLightGroupProcessForm(groupInfo, GroupOperateType.DELETE); workflowService.start(ProcessName.DELETE_LIGHT_GROUP_PROCESS, operator, lightForm); break; default: throw new WorkflowListenerException(ErrorCodeEnum.GROUP_MODE_UNSUPPORTED.getMessage()); } } /** * Generate the form of [New Group Workflow] */ public NewGroupProcessForm genNewGroupProcessForm(String groupId) { NewGroupProcessForm form = new NewGroupProcessForm(); InlongGroupInfo groupInfo = groupService.get(groupId); form.setGroupInfo(groupInfo); List<StreamBriefResponse> infoList = streamService.getBriefList(groupInfo.getInlongGroupId()); form.setStreamInfoList(infoList); return form; } private UpdateGroupProcessForm genUpdateGroupProcessForm(InlongGroupInfo groupInfo, GroupOperateType operateType) { UpdateGroupProcessForm form = new UpdateGroupProcessForm(); String groupId = groupInfo.getInlongGroupId(); if (GroupOperateType.RESTART == operateType) { List<InlongStreamInfo> streamList = streamService.list(groupId); form.setStreamInfos(streamList); } form.setGroupInfo(groupInfo); form.setGroupOperateType(operateType); return form; } private LightGroupResourceProcessForm genLightGroupProcessForm(InlongGroupInfo groupInfo, GroupOperateType operateType) { LightGroupResourceProcessForm form = new LightGroupResourceProcessForm(); form.setGroupInfo(groupInfo); String groupId = groupInfo.getInlongGroupId(); List<InlongStreamInfo> streamList = streamService.list(groupId); form.setStreamInfos(streamList); form.setGroupOperateType(operateType); return form; } }
46.243816
120
0.695652
0027925fd6352815aac142f57faab707308bedec
7,497
package com.xinonix.retrofhir.interactor; import java.util.Date; import com.xinonix.hl7.fhir.stu3.CodeableConcept; import com.xinonix.hl7.fhir.stu3.Identifier; import com.xinonix.retrofhir.Parameters; import com.xinonix.retrofhir.Prefix; import com.xinonix.retrofhir.Modifier; import com.xinonix.retrofhir.service.ProcedureRequestService; import com.xinonix.hl7.fhir.stu3.ProcedureRequest; public class ProcedureRequestInteractor extends ResourceInteractor<ProcedureRequestService, ProcedureRequest> { public static class ProcedureRequestComposer extends Composer<ProcedureRequestService, ProcedureRequest, ProcedureRequestComposer> { public ProcedureRequestComposer() { super((Class) ProcedureRequestService.class, (Class) ProcedureRequest.class); } public ResourceInteractor.Composer setAuthored(Modifier modifier, Prefix prefix, Date Authored) { return setParameter(Parameters.AUTHORED, modifier, prefix, Authored); } public ResourceInteractor.Composer setAuthored(Modifier modifier, Date Authored) { return setParameter(Parameters.AUTHORED, modifier, Authored); } public ResourceInteractor.Composer setAuthored(Prefix prefix, Date Authored) { return setParameter(Parameters.AUTHORED, prefix, Authored); } public ResourceInteractor.Composer setAuthored(Date Authored) { return setParameter(Parameters.AUTHORED, Authored); } public ResourceInteractor.Composer setBodySite(Modifier modifier, Prefix prefix, CodeableConcept BodySite) { return setParameter(Parameters.BODY_SITE, modifier, prefix, BodySite); } public ResourceInteractor.Composer setBodySite(Modifier modifier, CodeableConcept BodySite) { return setParameter(Parameters.BODY_SITE, modifier, BodySite); } public ResourceInteractor.Composer setBodySite(Prefix prefix, CodeableConcept BodySite) { return setParameter(Parameters.BODY_SITE, prefix, BodySite); } public ResourceInteractor.Composer setBodySite(CodeableConcept BodySite) { return setParameter(Parameters.BODY_SITE, BodySite); } public ResourceInteractor.Composer setCode(Modifier modifier, Prefix prefix, CodeableConcept Code) { return setParameter(Parameters.CODE, modifier, prefix, Code); } public ResourceInteractor.Composer setCode(Modifier modifier, CodeableConcept Code) { return setParameter(Parameters.CODE, modifier, Code); } public ResourceInteractor.Composer setCode(Prefix prefix, CodeableConcept Code) { return setParameter(Parameters.CODE, prefix, Code); } public ResourceInteractor.Composer setCode(CodeableConcept Code) { return setParameter(Parameters.CODE, Code); } public ResourceInteractor.Composer setIdentifier(Modifier modifier, Prefix prefix, Identifier Identifier) { return setParameter(Parameters.IDENTIFIER, modifier, prefix, Identifier); } public ResourceInteractor.Composer setIdentifier(Modifier modifier, Identifier Identifier) { return setParameter(Parameters.IDENTIFIER, modifier, Identifier); } public ResourceInteractor.Composer setIdentifier(Prefix prefix, Identifier Identifier) { return setParameter(Parameters.IDENTIFIER, prefix, Identifier); } public ResourceInteractor.Composer setIdentifier(Identifier Identifier) { return setParameter(Parameters.IDENTIFIER, Identifier); } public ResourceInteractor.Composer setIntent(Modifier modifier, Prefix prefix, String Intent) { return setParameter(Parameters.INTENT, modifier, prefix, Intent); } public ResourceInteractor.Composer setIntent(Modifier modifier, String Intent) { return setParameter(Parameters.INTENT, modifier, Intent); } public ResourceInteractor.Composer setIntent(Prefix prefix, String Intent) { return setParameter(Parameters.INTENT, prefix, Intent); } public ResourceInteractor.Composer setIntent(String Intent) { return setParameter(Parameters.INTENT, Intent); } public ResourceInteractor.Composer setOccurrence(Modifier modifier, Prefix prefix, Date Occurrence) { return setParameter(Parameters.OCCURRENCE, modifier, prefix, Occurrence); } public ResourceInteractor.Composer setOccurrence(Modifier modifier, Date Occurrence) { return setParameter(Parameters.OCCURRENCE, modifier, Occurrence); } public ResourceInteractor.Composer setOccurrence(Prefix prefix, Date Occurrence) { return setParameter(Parameters.OCCURRENCE, prefix, Occurrence); } public ResourceInteractor.Composer setOccurrence(Date Occurrence) { return setParameter(Parameters.OCCURRENCE, Occurrence); } public ResourceInteractor.Composer setPerformerType(Modifier modifier, Prefix prefix, CodeableConcept PerformerType) { return setParameter(Parameters.PERFORMER_TYPE, modifier, prefix, PerformerType); } public ResourceInteractor.Composer setPerformerType(Modifier modifier, CodeableConcept PerformerType) { return setParameter(Parameters.PERFORMER_TYPE, modifier, PerformerType); } public ResourceInteractor.Composer setPerformerType(Prefix prefix, CodeableConcept PerformerType) { return setParameter(Parameters.PERFORMER_TYPE, prefix, PerformerType); } public ResourceInteractor.Composer setPerformerType(CodeableConcept PerformerType) { return setParameter(Parameters.PERFORMER_TYPE, PerformerType); } public ResourceInteractor.Composer setPriority(Modifier modifier, Prefix prefix, String Priority) { return setParameter(Parameters.PRIORITY, modifier, prefix, Priority); } public ResourceInteractor.Composer setPriority(Modifier modifier, String Priority) { return setParameter(Parameters.PRIORITY, modifier, Priority); } public ResourceInteractor.Composer setPriority(Prefix prefix, String Priority) { return setParameter(Parameters.PRIORITY, prefix, Priority); } public ResourceInteractor.Composer setPriority(String Priority) { return setParameter(Parameters.PRIORITY, Priority); } public ResourceInteractor.Composer setRequisition(Modifier modifier, Prefix prefix, Identifier Requisition) { return setParameter(Parameters.REQUISITION, modifier, prefix, Requisition); } public ResourceInteractor.Composer setRequisition(Modifier modifier, Identifier Requisition) { return setParameter(Parameters.REQUISITION, modifier, Requisition); } public ResourceInteractor.Composer setRequisition(Prefix prefix, Identifier Requisition) { return setParameter(Parameters.REQUISITION, prefix, Requisition); } public ResourceInteractor.Composer setRequisition(Identifier Requisition) { return setParameter(Parameters.REQUISITION, Requisition); } public ResourceInteractor.Composer setStatus(Modifier modifier, Prefix prefix, String Status) { return setParameter(Parameters.STATUS, modifier, prefix, Status); } public ResourceInteractor.Composer setStatus(Modifier modifier, String Status) { return setParameter(Parameters.STATUS, modifier, Status); } public ResourceInteractor.Composer setStatus(Prefix prefix, String Status) { return setParameter(Parameters.STATUS, prefix, Status); } public ResourceInteractor.Composer setStatus(String Status) { return setParameter(Parameters.STATUS, Status); } } public static <T> ProcedureRequestInteractor.ProcedureRequestComposer Composer() { return new ProcedureRequestComposer(); } }
32.595652
136
0.776844
89bd824e5cd3b4b53c2589f8c2c8e69c92006ec0
4,826
/* * Copyright (c) 2011-2025 PiChen */ package com.interface21.orm.hibernate; import com.interface21.dao.CleanupFailureDataAccessException; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import net.sf.hibernate.FlushMode; /** * This interceptor binds a new Hibernate Session to the thread before a method * call, closing and removing it afterwards in case of any method outcome. * If there already was a pre-bound Session (e.g. from HibernateTransactionManager, * or from a surrounding Hibernate-intercepted method), the interceptor simply * takes part in it. * <p> * <p>Application code must retrieve a Hibernate Session via SessionFactoryUtils' * getSession method, to be able to detect a thread-bound Session. It is preferable * to use getSession with allowCreate=false, as the code relies on the interceptor * to provide proper Session handling. Typically the code will look as follows: * <p> * <p><code> * public void doHibernateAction() {<br> * &nbsp;&nbsp;Session session = SessionFactoryUtils.getSession(this.sessionFactory, false);<br> * &nbsp;&nbsp;try {<br> * &nbsp;&nbsp;&nbsp;&nbsp;...<br> * &nbsp;&nbsp;}<br> * &nbsp;&nbsp;catch (HibernateException ex) {<br> * &nbsp;&nbsp;&nbsp;&nbsp;throw SessionFactoryUtils.convertHibernateAccessException(ex);<br> * &nbsp;&nbsp;}<br> * } * </code> * <p> * <p>Note that the application must care about handling HibernateExceptions itself, * preferably via delegating to SessionFactoryUtils' convertHibernateAccessException * that converts them to ones that are compatible with the com.interface21.dao * exception hierarchy (like HibernateTemplate does). * <p> * <p>Unfortunately, this interceptor cannot convert checked HibernateExceptions * to unchecked dao ones automatically. The intercepted method would have to throw * HibernateException to be able to achieve this - thus the caller would still have * to catch or rethrow it, even if it will never be thrown if intercepted. * <p> * <p>This class can be considered a declarative alternative to HibernateTemplate's * callback approach. The advantages are: * <ul> * <li>no anonymous classes necessary for callback implementations; * <li>the possibility to throw any application exceptions from within data access code. * </ul> * The drawbacks are: * <ul> * <li>the dependency on interceptor configuration; * <li>the delegating try/catch blocks. * </ul> * <p> * <p>Note: This class, like all of Spring's Hibernate support, requires * Hibernate 2.0 (initially developed with RC1). * * @author Juergen Hoeller * @see SessionFactoryUtils#getSession * @see HibernateTransactionManager * @see HibernateTemplate * @since 13.06.2003 */ public class HibernateInterceptor extends HibernateAccessor implements MethodInterceptor { private final Log logger = LogFactory.getLog(getClass()); public Object invoke(MethodInvocation methodInvocation) throws Throwable { SessionHolder sessionHolder = null; if (!SessionFactoryUtils.getThreadObjectManager().hasThreadObject(getSessionFactory())) { logger.debug("Using new Session for Hibernate interceptor"); sessionHolder = new SessionHolder(SessionFactoryUtils.getSession(getSessionFactory(), getEntityInterceptor())); if (getFlushMode() == FLUSH_NEVER) { sessionHolder.getSession().setFlushMode(FlushMode.NEVER); } SessionFactoryUtils.getThreadObjectManager().bindThreadObject(getSessionFactory(), sessionHolder); } else { logger.debug("Found thread-bound Session for Hibernate interceptor"); } try { Object retVal = methodInvocation.proceed(); if (isFlushNecessary(sessionHolder == null)) { SessionHolder flushHolder = (SessionHolder) SessionFactoryUtils.getThreadObjectManager().getThreadObject(getSessionFactory()); flushHolder.getSession().flush(); } return retVal; } finally { if (sessionHolder != null) { SessionFactoryUtils.getThreadObjectManager().removeThreadObject(getSessionFactory()); try { SessionFactoryUtils.closeSessionIfNecessary(sessionHolder.getSession(), getSessionFactory()); } catch (CleanupFailureDataAccessException ex) { // just log it, to keep an invocation-related exception logger.error("Cannot close Hibernate Session after method interception", ex); } } else { logger.debug("Not closing pre-bound Hibernate Session after interceptor"); } } } }
44.275229
142
0.70949
5935b647bed8e1a245e34e27be489d39f0284f2d
495
package Exercicios; import java.util.Scanner; import javax.swing.JOptionPane; public class Modelo1 { public static void main(String[] args) { int num; num=Integer.parseInt(JOptionPane.showInputDialog ("Digite um numero:")); System.out.println(num); if (num%2==0) JOptionPane.showMessageDialog (null,"O numero é par"); else JOptionPane.showMessageDialog (null,"O numero é ímpar"); } }
20.625
80
0.59596
b531ffb17e9e0897cc088defb1dba05133ead469
1,647
package io.odpf.firehose.config; import io.odpf.firehose.config.converter.MongoSinkMessageTypeConverter; import io.odpf.firehose.config.enums.MongoSinkMessageType; public interface MongoSinkConfig extends AppConfig { @Key("SINK_MONGO_CONNECT_TIMEOUT_MS") @DefaultValue("30000") int getSinkMongoConnectTimeoutMs(); @Key("SINK_MONGO_CONNECTION_URLS") String getSinkMongoConnectionUrls(); @Key("SINK_MONGO_DB_NAME") String getSinkMongoDBName(); @Key("SINK_MONGO_RETRY_STATUS_CODE_BLACKLIST") @DefaultValue("11000") String getSinkMongoRetryStatusCodeBlacklist(); @Key("SINK_MONGO_PRESERVE_PROTO_FIELD_NAMES_ENABLE") @DefaultValue("true") Boolean isSinkMongoPreserveProtoFieldNamesEnable(); @Key("SINK_MONGO_AUTH_ENABLE") @DefaultValue("false") Boolean isSinkMongoAuthEnable(); @Key("SINK_MONGO_AUTH_USERNAME") String getSinkMongoAuthUsername(); @Key("SINK_MONGO_AUTH_PASSWORD") String getSinkMongoAuthPassword(); @Key("SINK_MONGO_AUTH_DB") String getSinkMongoAuthDB(); @Key("SINK_MONGO_INPUT_MESSAGE_TYPE") @ConverterClass(MongoSinkMessageTypeConverter.class) @DefaultValue("JSON") MongoSinkMessageType getSinkMongoInputMessageType(); @Key("SINK_MONGO_COLLECTION_NAME") String getSinkMongoCollectionName(); @Key("SINK_MONGO_PRIMARY_KEY") String getSinkMongoPrimaryKey(); @Key("SINK_MONGO_MODE_UPDATE_ONLY_ENABLE") @DefaultValue("false") Boolean isSinkMongoModeUpdateOnlyEnable(); @Key("SINK_MONGO_SERVER_SELECT_TIMEOUT_MS") @DefaultValue("30000") int getSinkMongoServerSelectTimeoutMs(); }
27.915254
71
0.761384
6c1b2ec6fd01c0e22f3b3e554522392efbd37978
14,138
import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.HashSet; import java.util.Optional; import java.util.Scanner; import java.util.Set; import java.util.stream.Collectors; class Solution { private static class Map { private final int rowCount; private final int columnCount; private final MapElement[][] mapElements; private MapElement startingPoint; private MapElement teleporter1; private MapElement teleporter2; private Map(int rowCount, int columnCount, MapElement[][] mapElements) { this.rowCount = rowCount; this.columnCount = columnCount; this.mapElements = mapElements; initializeStartingPointAndTeleporters(); } private void initializeStartingPointAndTeleporters() { for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) { if (mapElements[rowIndex][columnIndex].getMapElementType().equals(MapElementType.STARTING_POINT)) { this.startingPoint = mapElements[rowIndex][columnIndex]; } else if (mapElements[rowIndex][columnIndex].getMapElementType().equals(MapElementType.TELEPORTER)) { if (teleporter1 == null) { this.teleporter1 = mapElements[rowIndex][columnIndex]; } else if (teleporter2 == null) { this.teleporter2 = mapElements[rowIndex][columnIndex]; } } } } } public MapElement getStartingPoint() { return startingPoint; } public boolean tryMove(Bender bender) { return getNextMapElement(bender.getRowIndex(), bender.getColumnIndex(), bender.getDirection()).tryMove(this, bender); } public MapElement getNextMapElement(int rowIndex, int columnIndex, Direction direction) { switch (direction) { case NORTH: return mapElements[rowIndex - 1][columnIndex]; case SOUTH: return mapElements[rowIndex + 1][columnIndex]; case WEST: return mapElements[rowIndex][columnIndex - 1]; case EAST: return mapElements[rowIndex][columnIndex + 1]; default: throw new IllegalArgumentException("Unable to switch on the provided direction!"); } } public MapElement getTeleportingPoint(MapElement mapElement) { if (mapElement.equals(teleporter1)) { return teleporter2; } if (mapElement.equals(teleporter2)) { return teleporter1; } throw new IllegalArgumentException("There is no teleporting point from the map element provided as argument."); } public static MapElement[] parseRowFromString(int rowIndex, String rowAsString) { MapElement[] row = new MapElement[rowAsString.length()]; for (int columnIndex = 0; columnIndex < row.length; columnIndex++) { row[columnIndex] = MapElement.parseFromChar(rowIndex, columnIndex, rowAsString.charAt(columnIndex)); } return row; } } private static class MapElement { private final int rowIndex; private final int columnIndex; private MapElementType mapElementType; private MapElement(int rowIndex, int columnIndex, MapElementType mapElementType) { this.rowIndex = rowIndex; this.columnIndex = columnIndex; this.mapElementType = mapElementType; } public boolean tryMove(Map map, Bender bender) { return mapElementType.tryMove(map, bender, this); } public int getRowIndex() { return rowIndex; } public int getColumnIndex() { return columnIndex; } public MapElementType getMapElementType() { return mapElementType; } public void destroy() { if (mapElementType.equals(MapElementType.BREAKABLE_OBSTACLE)) { mapElementType = MapElementType.BLANK; } else { throw new UnsupportedOperationException("Only breakable obstacle can be destroyed."); } } public static MapElement parseFromChar(int rowIndex, int columnIndex, char mapElementAsChar) { return new MapElement(rowIndex, columnIndex, MapElementType.parseFromChar(mapElementAsChar)); } } private static enum MapElementType { STARTING_POINT { @Override public boolean tryMove(Map map, Bender bender, MapElement mapElement) { throw new IllegalStateException("Bender should never return to the starting point!"); } }, SUICIDE_BOOTH { @Override public boolean tryMove(Map map, Bender bender, MapElement mapElement) { bender.updatePosition(mapElement); bender.commitSuicide(); return true; } }, UNBREAKABLE_OBSTACLE { @Override public boolean tryMove(Map map, Bender bender, MapElement mapElement) { return false; } }, BREAKABLE_OBSTACLE { @Override public boolean tryMove(Map map, Bender bender, MapElement mapElement) { if (bender.isBreakerModeEnabled()) { bender.destroyObstacle(mapElement); bender.updatePosition(mapElement); return true; } else { return false; } } }, SOUTH_PATH_MODIFIER { @Override public boolean tryMove(Map map, Bender bender, MapElement mapElement) { bender.acquirePathModifier(Direction.SOUTH); bender.updatePosition(mapElement); return true; } }, EAST_PATH_MODIFIER { @Override public boolean tryMove(Map map, Bender bender, MapElement mapElement) { bender.acquirePathModifier(Direction.EAST); bender.updatePosition(mapElement); return true; } }, NORTH_PATH_MODIFIER { @Override public boolean tryMove(Map map, Bender bender, MapElement mapElement) { bender.acquirePathModifier(Direction.NORTH); bender.updatePosition(mapElement); return true; } }, WEST_PATH_MODIFIER { @Override public boolean tryMove(Map map, Bender bender, MapElement mapElement) { bender.acquirePathModifier(Direction.WEST); bender.updatePosition(mapElement); return true; } }, CIRCUIT_INVERTER { @Override public boolean tryMove(Map map, Bender bender, MapElement mapElement) { bender.changeReverseMode(); bender.updatePosition(mapElement); return true; } }, BEER { @Override public boolean tryMove(Map map, Bender bender, MapElement mapElement) { bender.changeBreakerMode(); bender.updatePosition(mapElement); return true; } }, TELEPORTER { @Override public boolean tryMove(Map map, Bender bender, MapElement mapElement) { bender.updatePosition(map.getTeleportingPoint(mapElement)); return true; } }, BLANK { @Override public boolean tryMove(Map map, Bender bender, MapElement mapElement) { bender.updatePosition(mapElement); return true; } }; public static MapElementType parseFromChar(char mapElementTypeAsChar) { switch (mapElementTypeAsChar) { case '@': return STARTING_POINT; case '$': return SUICIDE_BOOTH; case '#': return UNBREAKABLE_OBSTACLE; case 'X': return BREAKABLE_OBSTACLE; case 'N': return NORTH_PATH_MODIFIER; case 'S': return SOUTH_PATH_MODIFIER; case 'W': return WEST_PATH_MODIFIER; case 'E': return EAST_PATH_MODIFIER; case 'I': return CIRCUIT_INVERTER; case 'B': return BEER; case 'T': return TELEPORTER; case ' ': return BLANK; default: throw new IllegalArgumentException("Unable to parse string."); } } public abstract boolean tryMove(Map map, Bender bender, MapElement mapElement); } private static class Bender { private class BenderState { private int rowIndex; private int columnIndex; private Direction direction; private boolean isDead; private boolean isInLoop; private boolean isReverseModeEnabled; private boolean isBreakerModeEnabled; private Optional<Direction> pathModifier = Optional.empty(); public BenderState copy() { BenderState benderState = new BenderState(); benderState.rowIndex = this.rowIndex; benderState.columnIndex = this.columnIndex; benderState.direction = this.direction; benderState.isDead = this.isDead; benderState.isInLoop = this.isInLoop; benderState.isReverseModeEnabled = this.isReverseModeEnabled; benderState.isBreakerModeEnabled = this.isBreakerModeEnabled; benderState.pathModifier = this.pathModifier; return benderState; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + columnIndex; result = prime * result + rowIndex; result = prime * result + ((direction == null) ? 0 : direction.hashCode()); result = prime * result + (isBreakerModeEnabled ? 1231 : 1237); result = prime * result + (isReverseModeEnabled ? 1231 : 1237); return result; } @Override public boolean equals(Object that) { if (this == that) return true; if (that == null) return false; if (getClass() != that.getClass()) return false; BenderState other = (BenderState) that; if (rowIndex != other.rowIndex) return false; if (columnIndex != other.columnIndex) return false; if (direction != other.direction) return false; if (isReverseModeEnabled != other.isReverseModeEnabled) return false; if (isBreakerModeEnabled != other.isBreakerModeEnabled) return false; return true; } } private final BenderState benderState; private final Set<BenderState> previousStates; private Bender(int rowIndex, int columnIndex) { this.benderState = new BenderState(); this.previousStates = new HashSet<>(); initializeBenderState(rowIndex, columnIndex); } private void initializeBenderState(int rowIndex, int columnIndex) { this.benderState.rowIndex = rowIndex; this.benderState.columnIndex = columnIndex; this.benderState.direction = Direction.SOUTH; this.benderState.isDead = false; this.benderState.isInLoop = false; this.benderState.isReverseModeEnabled = false; this.benderState.isBreakerModeEnabled = false; this.benderState.pathModifier = Optional.empty(); } public int getRowIndex() { return this.benderState.rowIndex; } public int getColumnIndex() { return this.benderState.columnIndex; } public Direction getDirection() { return this.benderState.direction; } public boolean isDead() { return this.benderState.isDead; } public boolean isInLoop() { return this.benderState.isInLoop; } public boolean isBreakerModeEnabled() { return this.benderState.isBreakerModeEnabled; } public void commitSuicide() { this.benderState.isDead = true; } public void changeReverseMode() { this.benderState.isReverseModeEnabled = !this.benderState.isReverseModeEnabled; } public void changeBreakerMode() { this.benderState.isBreakerModeEnabled = !this.benderState.isBreakerModeEnabled; } public void acquirePathModifier(Direction direction) { this.benderState.pathModifier = Optional.of(direction); } public void destroyObstacle(MapElement obstacle) { obstacle.destroy(); this.previousStates.clear(); } public void updatePosition(MapElement mapElement) { this.benderState.rowIndex = mapElement.getRowIndex(); this.benderState.columnIndex = mapElement.getColumnIndex(); } public void move(Map map) { consumePathModifierIfPresent(); if (!map.tryMove(this)) { tryMoveInDifferentDirections(map); } checkForLoop(); } private void consumePathModifierIfPresent() { if (this.benderState.pathModifier.isPresent()) { this.benderState.direction = this.benderState.pathModifier.get(); this.benderState.pathModifier = Optional.empty(); } } private void tryMoveInDifferentDirections(Map map) { for (Direction direction : getDirectionsByPriority()) { changeDirection(direction); if (map.tryMove(this)) { return; } } throw new IllegalStateException("It seems that the poor Bender is trapped."); } private void changeDirection(Direction direction) { this.benderState.direction = direction; } private Collection<Direction> getDirectionsByPriority() { if (this.benderState.isReverseModeEnabled) { return Direction.getDirectionsByAscendingPriority(); } else { return Direction.getDirectionsByDescendingPriority(); } } private void checkForLoop() { if (!this.previousStates.add(this.benderState.copy())) { this.benderState.isInLoop = true; } } } private static enum Direction { SOUTH(3), EAST(2), NORTH(1), WEST(0); private static final Collection<Direction> DIRECTIONS_BY_ASCENDING_PRIORITY = Arrays.stream(Direction.values()).sorted(Comparator.comparingInt(Direction::getPriority)).collect(Collectors.toList()); private static final Collection<Direction> DIRECTIONS_BY_DESCENDING_PRIORITY = Arrays.stream(Direction.values()).sorted(Comparator.comparingInt(Direction::getPriority).reversed()).collect(Collectors.toList()); private final int priority; private Direction(int priority) { this.priority = priority; } public int getPriority() { return priority; } public static Collection<Direction> getDirectionsByAscendingPriority() { return DIRECTIONS_BY_ASCENDING_PRIORITY; } public static Collection<Direction> getDirectionsByDescendingPriority() { return DIRECTIONS_BY_DESCENDING_PRIORITY; } } public static void main(String args[]) { Scanner in = new Scanner(System.in); int L = in.nextInt(); int C = in.nextInt(); in.nextLine(); MapElement[][] mapElements = new MapElement[L][C]; for (int i = 0; i < L; i++) { String rowAsString = in.nextLine(); mapElements[i] = Map.parseRowFromString(i, rowAsString); } Map map = new Map(L, C, mapElements); Bender bender = new Bender(map.getStartingPoint().getRowIndex(), map.getStartingPoint().getColumnIndex()); StringBuilder moves = new StringBuilder(); while (!bender.isDead() && !bender.isInLoop()) { bender.move(map); moves.append(bender.getDirection()).append('\n'); } moves.setLength(moves.length() - 1); System.out.println(bender.isInLoop() ? "LOOP" : moves.toString()); } }
27.613281
211
0.701019
210349615053f0b1620226f1e2471a0b274b25d5
192
package com.zcy.hello.springboot.mybatis.mapper; import com.zcy.hello.springboot.mybatis.entity.TbItem; import tk.mybatis.MyMapper; public interface TbItemMapper extends MyMapper<TbItem> { }
27.428571
56
0.822917
9521a2a9c00e8e7f5a6934274b84bb885a7a6eb6
1,983
/** * Copyright (C) 2016 - 2030 youtongluan. * * 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.yx.bean.watcher; import java.io.InputStream; import java.util.List; import org.yx.bean.IOC; import org.yx.bean.Loader; import org.yx.bean.Plugin; import org.yx.log.Log; import org.yx.main.SumkServer; import org.yx.util.CollectionUtil; import org.yx.util.StringUtil; public class LifeCycleHandler { public static final LifeCycleHandler instance = new LifeCycleHandler(); private void runFromFile() { try { InputStream in = Loader.getResourceAsStream("sumk-exec"); if (in == null) { return; } List<String> list = CollectionUtil.loadList(in); for (String key : list) { if (StringUtil.isEmpty(key)) { continue; } Class<?> clz = Loader.loadClass(key); if (!Runnable.class.isAssignableFrom(clz)) { Log.get("sumk.SYS").info("{} should implements Runnable", clz.getSimpleName()); continue; } Runnable r = (Runnable) clz.newInstance(); r.run(); } } catch (Exception e) { Log.printStack(e); System.exit(-1); } } public void start() { startBeans(); runFromFile(); Runtime.getRuntime().addShutdownHook(new Thread(SumkServer::stop)); } private void startBeans() { List<Plugin> lifes = IOC.getBeans(Plugin.class); if (lifes == null || lifes.isEmpty()) { return; } lifes.forEach(Plugin::start); } }
27.164384
85
0.666667
1c8f0297030b95f032bb5f8bb917e92967e4c3f6
1,452
package bio.terra.stairway; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class TestStepCreateFile implements Step { private String filename; private String text; public TestStepCreateFile(String filename, String text) { this.filename = filename; this.text = text; } @Override public StepResult doStep(FlightContext context) { // We assume the file does not exist, since that was checked in the previous step // The createFileMetadata will fail if the file exists. try { Path filepath = Paths.get(filename); Files.createFile(filepath); Files.write(filepath, text.getBytes("UTF-8")); return StepResult.getStepResultSuccess(); } catch (IOException | RuntimeException ex) { return new StepResult(StepStatus.STEP_RESULT_FAILURE_FATAL, ex); } } @Override public StepResult undoStep(FlightContext context) { File file = new File(filename); // Non-existent file is not an error; failing to delete an existing file is if (file.exists() && !file.delete()) { return new StepResult(StepStatus.STEP_RESULT_FAILURE_FATAL, new IllegalArgumentException("Failed to delete File " + filename)); } return StepResult.getStepResultSuccess(); } }
33
89
0.659091
5813f6266410f7cd66f5a2f0b7128a41e86e56eb
922
package com.example.nctai_trading.coinbasePro; import com.google.gson.annotations.SerializedName; public class coinBaseBody { @SerializedName("price") private Double price; @SerializedName("size") private Double size; @SerializedName("side") private String side; @SerializedName("product_id") private String product_id; public Double getPrice() { return price; } public void setPrice(Double price) { this.price = price; } public Double getSize() { return size; } public void setSize(Double size) { this.size = size; } public String getSide() { return side; } public void setSide(String side) { this.side = side; } public String getProduct_id() { return product_id; } public void setProduct_id(String product_id) { this.product_id = product_id; } }
18.078431
50
0.624729
3730e7c0ff132cfb933be53effaf99e888d1a6f3
457
package com.grpc.java.service; import com.grpc.java.kernel.entity.IMDiscovery; import java.util.List; /** * Created by wx on 2017/10/27. */ public interface IDiscoveryService { IMDiscovery getDiscoveryById(Integer id); IMDiscovery getDiscoveryByName(String name); List<IMDiscovery> getAllDiscovery(); Boolean addDiscovery(IMDiscovery user); Boolean deleteDiscovery(Integer id); Boolean updateDiscovery(IMDiscovery user); }
19.869565
48
0.750547
3e5a2772c19ef73e3be97e9df8ce352058fe4ff6
1,416
/* * Copyright 2016 dc-square GmbH * * 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.hivemq.plugin.heartbeat.ioc; import com.hivemq.plugin.heartbeat.configuration.ConfigurationReader; import com.hivemq.plugin.heartbeat.configuration.HeartBeatConfiguration; import javax.inject.Inject; import javax.inject.Provider; /** * The provider which is responsible for creating the HeartBeatConfiguration object * * @author Dominik Obermaier */ public class HeartbeatConfigurationProvider implements Provider<HeartBeatConfiguration> { private final ConfigurationReader configReader; @Inject HeartbeatConfigurationProvider(final ConfigurationReader configReader) { this.configReader = configReader; } @Override public HeartBeatConfiguration get() { //We're actually reading the config file return configReader.readConfiguration(); } }
31.466667
89
0.757768
ae87673da5177ce2832c2b6157fce9b5fdf394c9
6,023
package com.kja.questions; import static spark.Spark.exception; import static spark.Spark.get; import static spark.Spark.post; import static spark.SparkBase.port; import static spark.SparkBase.staticFileLocation; import java.awt.Desktop; import java.io.File; import java.io.IOException; import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.net.URI; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.StandardOpenOption; import java.util.ArrayList; import java.util.List; import java.util.Map; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.kja.questions.QuestionsData.Answer; import com.kja.questions.QuestionsData.Question; /** * */ public class App { private static final int DEF_HTTP_PORT = 80; private static final String DATA_FILE = "data.json"; private static final String RESULTS_FILE = "results.log"; private static ObjectMapper mapper = initMapper(); private static QuestionsData data; public static ObjectMapper initMapper() { ObjectMapper om = new ObjectMapper(); om.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); om.setSerializationInclusion(JsonInclude.Include.NON_NULL); return om; } public static void main( String[] args ) throws Exception { data = loadData(); int port = setupWeb(DEF_HTTP_PORT); Thread.sleep(1000); String appUrl = null; System.out.println("Адрес приложения: "); String portStr = (port == DEF_HTTP_PORT ? "/" : (":"+port+"/")); for(String ip: NetUtils.getCurIPs(port)) { String url = ip + portStr; System.out.println(url); if(appUrl == null) appUrl = url; } if(appUrl == null) appUrl = "localhost"+portStr; try { Desktop.getDesktop().browse(new URI("http://"+appUrl)); } catch(Exception e) { System.out.println(e.getMessage()); } } private static int setupWeb(int portWant) throws Exception { int port = NetUtils.getAvailablePort(portWant); port(port); staticFileLocation("/web-static"); get("/", (req, res) -> { res.redirect("/index.html"); return ""; }); get("/init.json", (req, res) -> { QuestionsData qd = new QuestionsData(); qd.title = data.title; for(Question q : data.questions) { Question q1 = new Question(); qd.questions.add(q1); q1.question = q.question; for(Answer a : q.answers) { Answer a1 = new Answer(); q1.answers.add(a1); a1.text = a.text; } } String adr = req.raw().getRemoteAddr(); System.out.println(adr + " - вiдкрив тест"); return dataToJson(qd); }); get("/saveFio.json", (req, res) -> { String fio = req.queryParams("fio"); String adr = req.raw().getRemoteAddr(); System.out.println(adr + " - " +fio + " почав тест"); return ""; }); post("/checkResults.json", (req, res) -> { String body = new String(req.bodyAsBytes(), StandardCharsets.UTF_8); QuestionsData cd = mapper.readValue(body, QuestionsData.class); int right = 0; for (Question q : cd.questions) { Question qq = data.questions.get(q.id); int rightA = getRightA(qq); int usrA = q.a; if(usrA == rightA) right+=1; } QuestionsData qd = new QuestionsData(); qd.total = data.questions.size(); qd.right = right; qd.mark = getMark(qd.right, qd.total, data.grades); String adr = req.raw().getRemoteAddr(); String msg = adr + " - " + cd.fio + " закiнчив тест, оцiнка: " + qd.mark; List<String> msgl = new ArrayList<>(); msgl.add(msg); Files.write(new File(RESULTS_FILE).toPath(), msgl, StandardCharsets.UTF_8, StandardOpenOption.APPEND, StandardOpenOption.CREATE); System.out.println(msg); return dataToJson(qd); }); exception(Exception.class, (e, request, response) -> { response.status(500); response.body("Трапилась помилка: " + e.getMessage()); e.printStackTrace(); }); return port; } private static Integer getMark(Integer right, Integer total, Map<Integer, Double> grades) { double d = 1.0 * right / total; int mark = 0; for(Integer m : grades.keySet()) { if(mark > m) continue; Double limit = grades.get(m); if(d >= limit) mark = m; } return mark; } private static int getRightA(Question q) { int i = 0, rightA = -1; for(Answer a : q.answers) { if(a.right != null && a.right) { rightA = i; break; } i++; } return rightA; } public static class ServData { public String title = "hello title"; } public static String dataToJson(Object data) throws Exception { mapper.enable(SerializationFeature.INDENT_OUTPUT); StringWriter sw = new StringWriter(); mapper.writeValue(sw, data); return sw.toString(); } /* NewPostPayload creation = mapper.readValue(request.body(), NewPostPayload.class); if (!creation.isValid()) { response.status(HTTP_BAD_REQUEST); return ""; } int id = model.createPost(creation.getTitle(), creation.getContent(), creation.getCategories()); response.status(200); response.type("application/json"); return id; */ public static QuestionsData loadData() throws UnsupportedEncodingException, IOException, JsonParseException, JsonMappingException { String text = new String(Files.readAllBytes(new File(DATA_FILE).toPath()), "utf-8"); text = text.replace("\uFEFF", ""); // UTF-8 BOM //text = text.replace("\"", "||"); //text = text.replace("'", "\""); //text = text.replace("||", "\'"); ObjectMapper mapper = App.initMapper(); QuestionsData data = mapper.readValue(text, QuestionsData.class); System.out.println("Загружено вопросов: " + data.questions.size()); return data; } }
30.573604
99
0.688195
ca51bc450d67f69d00e4dbaca1888f7cac54756a
6,032
/******************************************************************************* * Copyright (c) 2011, 2014 Kyungpook National University and Contributors * * Contributor(s): - Hyun-Je Song *******************************************************************************/ package kr.ac.knu.ml.exec.extractor; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Date; import kr.ac.knu.ml.analyzer.BiomedicalAnalyzer; import kr.ac.knu.ml.document.ChildSurgeonDocument; import kr.ac.knu.ml.document.ImmunityDocument; import kr.ac.knu.ml.document.SurgeonDocument; import kr.ac.knu.ml.matcher.Matcher; import kr.ac.knu.ml.parser.BioMedicalDocumentParser; import kr.ac.knu.ml.writer.PAReportWriter; import org.apache.commons.cli.BasicParser; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.MissingArgumentException; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Sheet; /** * * To extract information from IHC reports <br/> * * @author Hyun-Je * */ public class PADocExtractor extends DocExtractor { public void sort(ArrayList<ImmunityDocument> idocs) throws IOException { long start = System.nanoTime(); Collections.sort(idocs, new Comparator<ImmunityDocument>() { public int compare(ImmunityDocument idoc1, ImmunityDocument idoc2) { return idoc1.getPatientNumber().compareTo( idoc2.getPatientNumber()); } }); long end = System.nanoTime(); System.out.println("Sorting time : " + (end - start) / Math.pow(10, 9) + " second"); } public void write(String outputFileName, ArrayList<ImmunityDocument> idocs) throws IOException { long start = System.nanoTime(); System.out.println("Write '" + outputFileName + "'"); PAReportWriter writeExcel = new PAReportWriter(); writeExcel.write(outputFileName + ".xlsx", idocs); long end = System.nanoTime(); System.out.println("Writing time : " + (end - start) / Math.pow(10, 9) + " second"); } private void extract(File inputFiles[], String outputFileName) throws InvalidFormatException, IOException { ArrayList<Sheet> sheets = getSheets(inputFiles); // intermediate result ArrayList<ImmunityDocument> idocs = new ArrayList<ImmunityDocument>(); ArrayList<SurgeonDocument> sdocs = new ArrayList<SurgeonDocument>(); ArrayList<ChildSurgeonDocument> csdocs = new ArrayList<ChildSurgeonDocument>(); // if you do not want to store an original text, set the last parameter // to false. BioMedicalDocumentParser bmdp = new BioMedicalDocumentParser(); bmdp.excelparse(sheets, idocs, sdocs, csdocs, false); BiomedicalAnalyzer ba = new BiomedicalAnalyzer(); ba.processingImmunityDocument(idocs); Matcher.matcherImmunityDocumentToSurgeonDocument(idocs, sdocs); ba.analysisImmunityDocumentSlide(idocs); ba.analysisImmunityDocumentForFindingDuplicates(idocs); sort(idocs); write(outputFileName, idocs); } private void extract(File inputFiles[], String outputFileName, String testPDoc) throws InvalidFormatException, IOException { ArrayList<Sheet> sheets = getSheets(inputFiles); // intermediate result ArrayList<ImmunityDocument> idocs = new ArrayList<ImmunityDocument>(); BioMedicalDocumentParser bmdp = new BioMedicalDocumentParser(); bmdp.excelparse(sheets, idocs, null, null, "PA", testPDoc, false); // bmdp.txtSNUparse(sheets, idocs, null, null); BiomedicalAnalyzer ba = new BiomedicalAnalyzer(); ba.processingImmunityDocument(idocs); ba.analysisImmunityDocumentSlide(idocs); ba.analysisImmunityDocumentForFindingDuplicates(idocs); sort(idocs); write(outputFileName, idocs); } public static void main(String[] args) throws InvalidFormatException, IOException { CommandLineParser parser = new BasicParser(); Options options = getOptions(); String inputFileName = null; String outputFileName = null; String pathlogyID = null; try { CommandLine line = parser.parse(options, args); if (line.hasOption("i")) inputFileName = line.getOptionValue("i"); if (line.hasOption("inputfile")) inputFileName = line.getOptionValue("inputfile"); if (line.hasOption("p")) pathlogyID = line.getOptionValue("p"); if (line.hasOption("pid")) pathlogyID = line.getOptionValue("pid"); if (line.hasOption("o")) outputFileName = line.getOptionValue("o"); if (line.hasOption("outputfile")) outputFileName = line.getOptionValue("outputfile"); if (outputFileName == null) { SimpleDateFormat formatter = new SimpleDateFormat("YYMMdd"); String today = formatter.format(new Date()); outputFileName = "[" + today + "]PA_Output"; } if (line.hasOption("h") || line.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("PADocExtractor [options]", options); System.exit(1); } } catch (MissingArgumentException e) { e.printStackTrace(); } catch (ParseException e) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("PADocExtractor [options]", options); System.exit(1); } PADocExtractor pae = new PADocExtractor(); File[] files = null; File inputFile = new File(inputFileName); if (inputFile.isDirectory()) files = inputFile.listFiles(); else files = new File[] { inputFile }; try { if (pathlogyID != null) pae.extract(files, outputFileName, pathlogyID); else pae.extract(files, outputFileName); } catch (InvalidFormatException ife) { ife.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } } }
34.272727
82
0.696452
ebd479595f44e4f9dfb8811b3f78f3270015715c
1,308
package com.hustlebar.hustic.index; import com.hustlebar.hustic.util.HusticClientWrapper; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.EntityBuilder; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPut; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import javax.json.JsonObject; import java.io.IOException; public class IndexRequest { private HusticClientWrapper wrapper; private String path; private JsonObject data; public IndexRequest(HusticClientWrapper wrapper, String path, JsonObject data) { this.wrapper = wrapper; this.path = path; this.data = data; } public IndexResponse execute() { final HttpClient client = wrapper.getHttpClient(); IndexResponse indexResponse = null; try { final HttpPut httpPut = new HttpPut(this.path); httpPut.setEntity(new StringEntity(this.data.toString(), ContentType.APPLICATION_JSON)); System.out.println(this.data.toString()); indexResponse = client.execute(httpPut, new IndexResponseHandler()); } catch (IOException ioe) { //TODO: Tham } return indexResponse; } }
30.418605
84
0.691131
fa9e29d395ad226ed485383a53a56909a1b588e2
552
package org.timecrafters.FreightFrenzy.HardwareTesting.Engines; import com.qualcomm.robotcore.eventloop.opmode.TeleOp; import org.cyberarm.engine.V2.CyberarmEngine; import org.timecrafters.FreightFrenzy.Competition.Common.Robot; import org.timecrafters.FreightFrenzy.HardwareTesting.States.VuforiaTestState; @TeleOp(name = "Vuforia Test", group = "testing") public class VuforiaTestEngine extends CyberarmEngine { @Override public void setup() { Robot robot = new Robot(this); addState(new VuforiaTestState(robot)); } }
30.666667
78
0.777174
1c2da85d0bf2332dbf77d2fbce9984b4ea8ba974
2,645
/* * Copyright The OpenTelemetry Authors * SPDX-License-Identifier: Apache-2.0 */ package io.opentelemetry.opentracingshim; import io.opentelemetry.api.baggage.Baggage; import io.opentelemetry.api.trace.Span; import io.opentelemetry.context.Context; import io.opentelemetry.context.propagation.TextMapPropagator; import io.opentracing.propagation.TextMapExtract; import io.opentracing.propagation.TextMapInject; import java.util.HashMap; import java.util.Map; import javax.annotation.Nullable; final class Propagation extends BaseShimObject { Propagation(TelemetryInfo telemetryInfo) { super(telemetryInfo); } public void injectTextMap(SpanContextShim contextShim, TextMapInject carrier) { Context context = Context.current().with(Span.wrap(contextShim.getSpanContext())); context = context.with(contextShim.getBaggage()); propagators().getTextMapPropagator().inject(context, carrier, TextMapSetter.INSTANCE); } @Nullable public SpanContextShim extractTextMap(TextMapExtract carrier) { Map<String, String> carrierMap = new HashMap<>(); for (Map.Entry<String, String> entry : carrier) { carrierMap.put(entry.getKey(), entry.getValue()); } Context context = propagators() .getTextMapPropagator() .extract(Context.current(), carrierMap, TextMapGetter.INSTANCE); Span span = Span.fromContext(context); if (!span.getSpanContext().isValid()) { return null; } return new SpanContextShim(telemetryInfo, span.getSpanContext(), Baggage.fromContext(context)); } static final class TextMapSetter implements TextMapPropagator.Setter<TextMapInject> { private TextMapSetter() {} public static final TextMapSetter INSTANCE = new TextMapSetter(); @Override public void set(TextMapInject carrier, String key, String value) { carrier.put(key, value); } } // We use Map<> instead of TextMap as we need to query a specified key, and iterating over // *all* values per key-query *might* be a bad idea. static final class TextMapGetter implements TextMapPropagator.Getter<Map<String, String>> { private TextMapGetter() {} public static final TextMapGetter INSTANCE = new TextMapGetter(); @Nullable @Override public Iterable<String> keys(Map<String, String> carrier) { return carrier.keySet(); } @Override public String get(Map<String, String> carrier, String key) { for (Map.Entry<String, String> entry : carrier.entrySet()) { if (key.equalsIgnoreCase(entry.getKey())) { return entry.getValue(); } } return null; } } }
31.117647
99
0.715312
62e4e61125ca77475f9db2e1b373e1fc9e26d626
339
package no.nav.data.catalog.policies.app; public class LocalAppStarter { public static void main(String[] args) { System.setProperty("spring.profiles.active", "local"); System.setProperty("ENVIRONMENT_CLASS", "preprod"); System.setProperty("NAIS_NAMESPACE", "default"); AppStarter.main(args); } }
28.25
62
0.675516
e7e6907aefbe99182f667dbbb5b6344d81c54df9
2,482
package at.o2xfs.xfs.v3.cdm; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import at.o2xfs.memory.databind.annotation.MemoryPropertyOrder; import at.o2xfs.memory.databind.annotation.win32.UShort; import at.o2xfs.xfs.cdm.MixType; import at.o2xfs.xfs.databind.annotation.XfsEnum16; @JsonDeserialize(builder = MixType3.Builder.class) @MemoryPropertyOrder({ "mixNumber", "mixType", "subType", "name" }) public class MixType3 { @JsonPOJOBuilder(withPrefix = "") public static class Builder { private int mixNumber; private MixType mixType; private int subType; private String name; public Builder() { } public Builder mixNumber(int mixNumber) { this.mixNumber = mixNumber; return this; } public Builder mixType(MixType mixType) { this.mixType = mixType; return this; } public Builder subType(int subType) { this.subType = subType; return this; } public Builder name(String name) { this.name = name; return this; } public MixType3 build() { return new MixType3(this); } } @UShort private final int mixNumber; @XfsEnum16 private final MixType mixType; @UShort private final int subType; private final String name; protected MixType3(Builder builder) { mixNumber = builder.mixNumber; mixType = builder.mixType; subType = builder.subType; name = builder.name; } public int getMixNumber() { return mixNumber; } public MixType getMixType() { return mixType; } public int getSubType() { return subType; } public String getName() { return name; } @Override public boolean equals(Object obj) { if (obj instanceof MixType3) { MixType3 mixType3 = (MixType3) obj; return new EqualsBuilder().append(mixNumber, mixType3.mixNumber).append(mixType, mixType3.mixType) .append(subType, mixType3.subType).append(name, mixType3.name).isEquals(); } return false; } @Override public int hashCode() { return new HashCodeBuilder().append(mixNumber).append(mixType).append(subType).append(name).toHashCode(); } @Override public String toString() { return new ToStringBuilder(this).append("mixNumber", mixNumber).append("mixType", mixType) .append("subType", subType).append("name", name).toString(); } }
22.563636
107
0.734891
e293d18556de12e7a6f403b0d499801274963c33
1,335
package org.jax.gweaver.variant.orthology.io; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; /** * Test the expander class. * * @author Matthew Gerring * */ public class ExpanderTest { private Expander expander; private static List<Path> allDirectories; @BeforeClass public static void innit() { allDirectories = new ArrayList<>(); } @AfterClass public static void checkGone() throws Exception { allDirectories.stream().forEach(dir->assertFalse(Files.exists(dir))); } @Before public void create() throws IOException { Path dir = Files.createTempDirectory("ExpanderDir"); this.expander = new Expander(dir, true); } @After public void clean() throws IOException { allDirectories.add(expander.getDir()); this.expander.close(); } @Test public void unzip1() throws Exception { Path path = Paths.get("src/test/resources/data/zip/hs_gtf/hg38_1.gtf.zip"); expander.expand(path); assertEquals(1, Files.list(expander.getDir()).count()); } }
22.25
80
0.733333
f82ea4b31aeaf764640e63cda6f677b695f6950c
2,274
package com.github.bjuvensjo.rsimulator.aop; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.io.File; import java.net.URISyntaxException; import java.nio.file.Paths; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration public class SpringAopAllianceSimulatorTest { @Autowired private AopAllianceSimulator aopAllianceSimulator; @Autowired private Foo foo; @Test public void testWithoutRootRelativePath() { aopAllianceSimulator.setRootPath(this.getClass()); aopAllianceSimulator.setUseRootRelativePath(false); String msg = foo.sayHello("Hello from " + getClass().getName()); assertEquals("Hello " + getClass().getName() + " from AopAllianceSimulator", msg); } @Test public void testWithRootRelativePath() throws URISyntaxException { String rootPath = Paths.get(getClass().getResource("/").toURI()).toString() + File.separator; aopAllianceSimulator.setRootPath(rootPath); aopAllianceSimulator.setUseRootRelativePath(true); String msg = foo.sayHello("Hi from " + getClass().getName()); assertEquals("Hello " + getClass().getName(), msg); } @Test public void testException() { aopAllianceSimulator.setRootPath(this.getClass()); aopAllianceSimulator.setUseRootRelativePath(false); try { foo.doThrow("Give me an exception"); fail("Exception expected"); } catch (BarException barException) { assertEquals("1", barException.getCode()); assertEquals("msg", barException.getMessage()); } } @Test public void testDoNotReturn() { aopAllianceSimulator.setRootPath(this.getClass()); aopAllianceSimulator.setUseRootRelativePath(false); try { foo.doNotReturn("Do not return"); } catch (Exception exception) { exception.printStackTrace(); fail(exception.getMessage()); } } }
33.940299
101
0.692612
4c063a0dbe59848eebc9a3f28ab2e7ebb5dc25bd
11,241
package objects; import gui.Color; import vector.Vector2f; import vector.Vector3f; public class SimpleBoxVoxelObject extends ShapedObject3 { int[][][] data; public SimpleBoxVoxelObject(int sizex, int sizey, int sizez) { data = new int[sizex][sizey][sizez]; } public SimpleBoxVoxelObject(int[][][] data) { this.data = data; } public void resetData() { for (int x = 0; x < data.length; x++) { for (int y = 0; y < data[x].length; y++) { for (int z = 0; z < data[x][y].length; z++) { data[x][y][z] = 0; } } } } public void set(int x, int y, int z, int value) { data[x][y][z] = value; } public void setData(int[][][] data) { this.data = data; } public void updateShapes() { this.deleteData(); int[][][] indicesFrontBack = new int[data.length + 1][data[0].length + 1][data[0][0].length + 1]; int[][][] indicesUpDown = new int[data.length + 1][data[0].length + 1][data[0][0].length + 1]; int[][][] indicesLeftRight = new int[data.length + 1][data[0].length + 1][data[0][0].length + 1]; Color color = Color.WHITE; Vector2f a = new Vector2f(0, 0); Vector2f b = new Vector2f(1, 0); Vector2f c = new Vector2f(1, 1); Vector2f d = new Vector2f(0, 1); Vector3f down = new Vector3f(0, -1, 0); Vector3f back = new Vector3f(0, 0, -1); Vector3f left = new Vector3f(-1, 0, 0); Vector3f front = new Vector3f(0, 0, 1); Vector3f right = new Vector3f(1, 0, 0); Vector3f up = new Vector3f(0, 1, 0); for (int x = 0; x < data.length; x++) { for (int y = 0; y < data[x].length; y++) { for (int z = 0; z < data[x][y].length; z++) { if (data[x][y][z] != 0) { // left if (x == 0) { addVertex(new Vector3f(x, y, z), color, a, left); indicesLeftRight[x][y][z] = getVertexCount() - 1; addVertex(new Vector3f(x, y, z + 1), color, b, left); indicesLeftRight[x][y][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x, y + 1, z + 1), color, c, left); indicesLeftRight[x][y + 1][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x, y + 1, z), color, d, left); indicesLeftRight[x][y + 1][z] = getVertexCount() - 1; } else { if (data[x - 1][y][z] == 0) { addVertex(new Vector3f(x, y, z), color, a, left); indicesLeftRight[x][y][z] = getVertexCount() - 1; addVertex(new Vector3f(x, y, z + 1), color, b, left); indicesLeftRight[x][y][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x, y + 1, z + 1), color, c, left); indicesLeftRight[x][y + 1][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x, y + 1, z), color, d, left); indicesLeftRight[x][y + 1][z] = getVertexCount() - 1; } } // right if (x == data.length - 1) { addVertex(new Vector3f(x + 1, y, z), color, a, right); indicesLeftRight[x + 1][y][z] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y + 1, z), color, d, right); indicesLeftRight[x + 1][y + 1][z] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y + 1, z + 1), color, c, right); indicesLeftRight[x + 1][y + 1][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y, z + 1), color, b, right); indicesLeftRight[x + 1][y][z + 1] = getVertexCount() - 1; } else { if (data[x + 1][y][z] == 0) { addVertex(new Vector3f(x + 1, y, z), color, a, right); indicesLeftRight[x + 1][y][z] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y + 1, z), color, d, right); indicesLeftRight[x + 1][y + 1][z] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y + 1, z + 1), color, c, right); indicesLeftRight[x + 1][y + 1][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y, z + 1), color, b, right); indicesLeftRight[x + 1][y][z + 1] = getVertexCount() - 1; } } // down if (y == 0) { addVertex(new Vector3f(x, y, z), color, a, down); indicesUpDown[x][y][z] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y, z), color, b, down); indicesUpDown[x + 1][y][z] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y, z + 1), color, c, down); indicesUpDown[x + 1][y][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x, y, z + 1), color, d, down); indicesUpDown[x][y][z + 1] = getVertexCount() - 1; } else { if (data[x][y - 1][z] == 0) { addVertex(new Vector3f(x, y, z), color, a, down); indicesUpDown[x][y][z] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y, z), color, b, down); indicesUpDown[x + 1][y][z] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y, z + 1), color, c, down); indicesUpDown[x + 1][y][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x, y, z + 1), color, d, down); indicesUpDown[x][y][z + 1] = getVertexCount() - 1; } } // up if (y == data[0].length - 1) { addVertex(new Vector3f(x, y + 1, z), color, a, up); indicesUpDown[x][y + 1][z] = getVertexCount() - 1; addVertex(new Vector3f(x, y + 1, z + 1), color, d, up); indicesUpDown[x][y + 1][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y + 1, z + 1), color, c, up); indicesUpDown[x + 1][y + 1][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y + 1, z), color, b, up); indicesUpDown[x + 1][y + 1][z] = getVertexCount() - 1; } else { if (data[x][y + 1][z] == 0) { addVertex(new Vector3f(x, y + 1, z), color, a, up); indicesUpDown[x][y + 1][z] = getVertexCount() - 1; addVertex(new Vector3f(x, y + 1, z + 1), color, d, up); indicesUpDown[x][y + 1][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y + 1, z + 1), color, c, up); indicesUpDown[x + 1][y + 1][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y + 1, z), color, b, up); indicesUpDown[x + 1][y + 1][z] = getVertexCount() - 1; } } // back if (z == 0) { addVertex(new Vector3f(x, y, z), color, a, back); indicesFrontBack[x][y][z] = getVertexCount() - 1; addVertex(new Vector3f(x, y + 1, z), color, d, back); indicesFrontBack[x][y + 1][z] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y + 1, z), color, c, back); indicesFrontBack[x + 1][y + 1][z] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y, z), color, b, back); indicesFrontBack[x + 1][y][z] = getVertexCount() - 1; } else { if (data[x][y][z - 1] == 0) { addVertex(new Vector3f(x, y, z), color, a, back); indicesFrontBack[x][y][z] = getVertexCount() - 1; addVertex(new Vector3f(x, y + 1, z), color, d, back); indicesFrontBack[x][y + 1][z] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y + 1, z), color, c, back); indicesFrontBack[x + 1][y + 1][z] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y, z), color, b, back); indicesFrontBack[x + 1][y][z] = getVertexCount() - 1; } } // front if (z == data.length - 1) { addVertex(new Vector3f(x, y, z + 1), color, a, front); indicesFrontBack[x][y][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y, z + 1), color, b, front); indicesFrontBack[x + 1][y][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y + 1, z + 1), color, c, front); indicesFrontBack[x + 1][y + 1][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x, y + 1, z + 1), color, d, front); indicesFrontBack[x][y + 1][z + 1] = getVertexCount() - 1; } else { if (data[x][y][z + 1] == 0) { addVertex(new Vector3f(x, y, z + 1), color, a, front); indicesFrontBack[x][y][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y, z + 1), color, b, front); indicesFrontBack[x + 1][y][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x + 1, y + 1, z + 1), color, c, front); indicesFrontBack[x + 1][y + 1][z + 1] = getVertexCount() - 1; addVertex(new Vector3f(x, y + 1, z + 1), color, d, front); indicesFrontBack[x][y + 1][z + 1] = getVertexCount() - 1; } } } } } } for (int x = 0; x < data.length; x++) { for (int y = 0; y < data[x].length; y++) { for (int z = 0; z < data[x][y].length; z++) { if (data[x][y][z] != 0) { // left if (x == 0) { addQuad(indicesLeftRight[x][y][z], 0, indicesLeftRight[x][y][z + 1], 0, indicesLeftRight[x][y + 1][z + 1], 0, indicesLeftRight[x][y + 1][z], 0); } else { if (data[x - 1][y][z] == 0) { addQuad(indicesLeftRight[x][y][z], 0, indicesLeftRight[x][y][z + 1], 0, indicesLeftRight[x][y + 1][z + 1], 0, indicesLeftRight[x][y + 1][z], 0); } } // right if (x == data.length - 1) { addQuad(indicesLeftRight[x + 1][y][z], 0, indicesLeftRight[x + 1][y + 1][z], 0, indicesLeftRight[x + 1][y + 1][z + 1], 0, indicesLeftRight[x + 1][y][z + 1], 0); } else { if (data[x + 1][y][z] == 0) { addQuad(indicesLeftRight[x + 1][y][z], 0, indicesLeftRight[x + 1][y + 1][z], 0, indicesLeftRight[x + 1][y + 1][z + 1], 0, indicesLeftRight[x + 1][y][z + 1], 0); } } // down if (y == 0) { addQuad(indicesUpDown[x][y][z], 0, indicesUpDown[x + 1][y][z], 0, indicesUpDown[x + 1][y][z + 1], 0, indicesUpDown[x][y][z + 1], 0); } else { if (data[x][y - 1][z] == 0) { addQuad(indicesUpDown[x][y][z], 0, indicesUpDown[x + 1][y][z], 0, indicesUpDown[x + 1][y][z + 1], 0, indicesUpDown[x][y][z + 1], 0); } } // up if (y == data[0].length - 1) { addQuad(indicesUpDown[x][y + 1][z], 0, indicesUpDown[x][y + 1][z + 1], 0, indicesUpDown[x + 1][y + 1][z + 1], 0, indicesUpDown[x + 1][y + 1][z], 0); } else { if (data[x][y + 1][z] == 0) { addQuad(indicesUpDown[x][y + 1][z], 0, indicesUpDown[x][y + 1][z + 1], 0, indicesUpDown[x + 1][y + 1][z + 1], 0, indicesUpDown[x + 1][y + 1][z], 0); } } // back if (z == 0) { addQuad(indicesFrontBack[x][y][z], 0, indicesFrontBack[x][y + 1][z], 0, indicesFrontBack[x + 1][y + 1][z], 0, indicesFrontBack[x + 1][y][z], 0); } else { if (data[x][y][z - 1] == 0) { addQuad(indicesFrontBack[x][y][z], 0, indicesFrontBack[x][y + 1][z], 0, indicesFrontBack[x + 1][y + 1][z], 0, indicesFrontBack[x + 1][y][z], 0); } } // front if (z == data.length - 1) { addQuad(indicesFrontBack[x][y][z + 1], 0, indicesFrontBack[x + 1][y][z + 1], 0, indicesFrontBack[x + 1][y + 1][z + 1], 0, indicesFrontBack[x][y + 1][z + 1], 0); } else { if (data[x][y][z + 1] == 0) { addQuad(indicesFrontBack[x][y][z + 1], 0, indicesFrontBack[x + 1][y][z + 1], 0, indicesFrontBack[x + 1][y + 1][z + 1], 0, indicesFrontBack[x][y + 1][z + 1], 0); } } } } } } this.prerender(); } }
40.876364
99
0.513655
375584fed3117d319107442415d8cd589bd678be
934
package org.clever.hinny.spring.config; import lombok.Data; import org.springframework.boot.autoconfigure.data.redis.RedisProperties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; import java.util.Collections; import java.util.Map; /** * 作者:lizw <br/> * 创建时间:2020/11/16 21:21 <br/> */ @ConfigurationProperties(prefix = Constant.Config_Multiple_Redis_Config) @Data public class MultipleRedisConfig { /** * 是否禁用MultipleRedis配置 */ private boolean disable = false; /** * 默认的数据源名称 */ private String defaultName = "default"; /** * Redis全局配置 */ @NestedConfigurationProperty private RedisProperties globalConfig = new RedisProperties(); /** * Redis数据源集合(数据源名称 --> 数据源配置) */ private Map<String, RedisProperties> redisMap = Collections.emptyMap(); }
24.578947
79
0.718415
acacf232476e598eadb813f15ffc9cafb73b08c3
331
import java.util.Scanner; class hello { public static void main(String[] args) { Scanner s =new Scanner(System.in); //System.out.println("wrong input"); System.out.println("please enter a number5"); int z = s.nextInt(); System.out.println(z); } }
25.461538
57
0.534743
838ff22cb1eefcefee5566c93ba5e1a560b7a367
24,167
/* * 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.sanselan.util; //import java.awt.Dimension; //import java.awt.Point; //import java.awt.Rectangle; //import java.awt.color.ICC_Profile; import java.io.File; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.Map; public final class Debug { public static void debug(String message) { System.out.println(message); } public static void debug(Object o) { System.out.println(o == null ? "null" : o.toString()); } public static String getDebug(String message) { return message; } public static void debug() { newline(); } public static void newline() { System.out.print(newline); } public static String getDebug(String message, int value) { return getDebug(message + ": " + (value)); } public static String getDebug(String message, double value) { return getDebug(message + ": " + (value)); } public static String getDebug(String message, String value) { return getDebug(message + " " + value); } public static String getDebug(String message, long value) { return getDebug(message + " " + Long.toString(value)); } public static String getDebug(String message, int v[]) { StringBuffer result = new StringBuffer(); if (v == null) result.append(message + " (" + null + ")" + newline); else { result.append(message + " (" + v.length + ")" + newline); for (int i = 0; i < v.length; i++) result.append("\t" + v[i] + newline); result.append(newline); } return result.toString(); } public static String getDebug(String message, byte v[]) { final int max = 250; return getDebug(message, v, max); } public static String getDebug(String message, byte v[], int max) { StringBuffer result = new StringBuffer(); if (v == null) result.append(message + " (" + null + ")" + newline); else { result.append(message + " (" + v.length + ")" + newline); for (int i = 0; i < max && i < v.length; i++) { int b = 0xff & v[i]; char c; if (b == 0 || b == 10 || b == 11 || b == 13) c = ' '; else c = (char) b; result.append("\t" + i + ": " + b + " (" + c + ", 0x" + Integer.toHexString(b) + ")" + newline); } if (v.length > max) result.append("\t" + "..." + newline); result.append(newline); } return result.toString(); } public static String getDebug(String message, char v[]) { StringBuffer result = new StringBuffer(); if (v == null) result.append(getDebug(message + " (" + null + ")") + newline); else { result.append(getDebug(message + " (" + v.length + ")") + newline); for (int i = 0; i < v.length; i++) result.append(getDebug("\t" + v[i] + " (" + (0xff & v[i])) + ")" + newline); result.append(newline); } return result.toString(); } private static long counter = 0; public static String getDebug(String message, java.util.List v) { StringBuffer result = new StringBuffer(); String suffix = " [" + counter++ + "]"; result.append(getDebug(message + " (" + v.size() + ")" + suffix) + newline); for (int i = 0; i < v.size(); i++) result.append(getDebug("\t" + v.get(i).toString() + suffix) + newline); result.append(newline); return result.toString(); } public static void debug(String message, Map map) { debug(getDebug(message, map)); } public static String getDebug(String message, Map map) { StringBuffer result = new StringBuffer(); if (map == null) return getDebug(message + " map: " + null); ArrayList keys = new ArrayList(map.keySet()); result.append(getDebug(message + " map: " + keys.size()) + newline); for (int i = 0; i < keys.size(); i++) { Object key = keys.get(i); Object value = map.get(key); result.append(getDebug("\t" + i + ": '" + key + "' -> '" + value + "'") + newline); } result.append(newline); return result.toString(); } public static boolean compare(String prefix, Map a, Map b) { return compare(prefix, a, b, null, null); } // public static String newline = System.getProperty("line.separator"); public static String newline = "\r\n"; private static void log(StringBuffer buffer, String s) { Debug.debug(s); if (buffer != null) buffer.append(s + newline); } public static boolean compare(String prefix, Map a, Map b, ArrayList ignore, StringBuffer buffer) { if ((a == null) && (b == null)) { log(buffer, prefix + " both maps null"); return true; } if (a == null) { log(buffer, prefix + " map a: null, map b: map"); return false; } if (b == null) { log(buffer, prefix + " map a: map, map b: null"); return false; } ArrayList keys_a = new ArrayList(a.keySet()); ArrayList keys_b = new ArrayList(b.keySet()); if (ignore != null) { keys_a.removeAll(ignore); keys_b.removeAll(ignore); } boolean result = true; for (int i = 0; i < keys_a.size(); i++) { Object key = keys_a.get(i); if (!keys_b.contains(key)) { log(buffer, prefix + "b is missing key '" + key + "' from a"); result = false; } else { keys_b.remove(key); Object value_a = a.get(key); Object value_b = b.get(key); if (!value_a.equals(value_b)) { log(buffer, prefix + "key(" + key + ") value a: " + value_a + ") != b: " + value_b + ")"); result = false; } } } for (int i = 0; i < keys_b.size(); i++) { Object key = keys_b.get(i); log(buffer, prefix + "a is missing key '" + key + "' from b"); result = false; } if (result) log(buffer, prefix + "a is the same as b"); return result; } private static final String byteQuadToString(int bytequad) { byte b1 = (byte) ((bytequad >> 24) & 0xff); byte b2 = (byte) ((bytequad >> 16) & 0xff); byte b3 = (byte) ((bytequad >> 8) & 0xff); byte b4 = (byte) ((bytequad >> 0) & 0xff); char c1 = (char) b1; char c2 = (char) b2; char c3 = (char) b3; char c4 = (char) b4; // return new String(new char[] { c1, c2, c3, c4 }); StringBuffer fStringBuffer = new StringBuffer(); fStringBuffer.append(new String(new char[]{ c1, c2, c3, c4 })); fStringBuffer.append(" bytequad: " + bytequad); fStringBuffer.append(" b1: " + b1); fStringBuffer.append(" b2: " + b2); fStringBuffer.append(" b3: " + b3); fStringBuffer.append(" b4: " + b4); return fStringBuffer.toString(); } // public static String getDebug(String message) // { // // StringBuffer result = new StringBuffer(); // // result.append(getDebug("ICC_Profile " + message + ": " // + ((value == null) ? "null" : value.toString())) // + newline); // if (value != null) // { // result.append(getDebug("\t getProfileClass: " // + byteQuadToString(value.getProfileClass())) // + newline); // result.append(getDebug("\t getPCSType: " // + byteQuadToString(value.getPCSType())) // + newline); // result.append(getDebug("\t getColorSpaceType() : " // + byteQuadToString(value.getColorSpaceType())) // + newline); // } // // return result.toString(); // // } public static String getDebug(String message, boolean value) { return getDebug(message + " " + ((value) ? ("true") : ("false"))); } public static String getDebug(String message, File file) { return getDebug(message + ": " + ((file == null) ? "null" : file.getPath())); } public static String getDebug(String message, Date value) { DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); return getDebug(message, (value == null) ? "null" : df.format(value)); } public static String getDebug(String message, Calendar value) { DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); return getDebug(message, (value == null) ? "null" : df.format(value .getTime())); } public static void debug(String message, Object value) { if (value == null) debug(message, "null"); else if (value instanceof char[]) debug(message, (char[]) value); else if (value instanceof byte[]) debug(message, (byte[]) value); else if (value instanceof int[]) debug(message, (int[]) value); else if (value instanceof String) debug(message, (String) value); else if (value instanceof java.util.List) debug(message, (java.util.List) value); else if (value instanceof Map) debug(message, (Map) value); // else if (value instanceof Object) // debug(message, (Object) value); // else if (value instanceof ICC_Profile) // debug(message, (ICC_Profile) value); else if (value instanceof File) debug(message, (File) value); else if (value instanceof Date) debug(message, (Date) value); else if (value instanceof Calendar) debug(message, (Calendar) value); else debug(message, value.toString()); } public static void debug(String message, Object value[]) { if (value == null) debug(message, "null"); debug(message, value.length); final int max = 10; for (int i = 0; i < value.length && i < max; i++) debug("\t" + i, value[i]); if (value.length > max) debug("\t..."); debug(); } public static String getDebug(String message, Object value) { if (value == null) return getDebug(message, "null"); else if (value instanceof Calendar) return getDebug(message, (Calendar) value); else if (value instanceof Date) return getDebug(message, (Date) value); else if (value instanceof File) return getDebug(message, (File) value); // else if (value instanceof ICC_Profile) // return getDebug(message, (ICC_Profile) value); else if (value instanceof Map) return getDebug(message, (Map) value); else if (value instanceof Map) return getDebug(message, (Map) value); // // else if (value instanceof Object) // getDebug(message, (Object) value); else if (value instanceof String) return getDebug(message, (String) value); else if (value instanceof byte[]) return getDebug(message, (byte[]) value); else if (value instanceof char[]) return getDebug(message, (char[]) value); else if (value instanceof int[]) return getDebug(message, (int[]) value); else if (value instanceof java.util.List) return getDebug(message, (java.util.List) value); else return getDebug(message, value.toString()); } public static String getType(Object value) { if (value == null) return "null"; else if (value instanceof Object[]) return "[Object[]: " + ((Object[]) value).length + "]"; else if (value instanceof char[]) return "[char[]: " + ((char[]) value).length + "]"; else if (value instanceof byte[]) return "[byte[]: " + ((byte[]) value).length + "]"; else if (value instanceof short[]) return "[short[]: " + ((short[]) value).length + "]"; else if (value instanceof int[]) return "[int[]: " + ((int[]) value).length + "]"; else if (value instanceof long[]) return "[long[]: " + ((long[]) value).length + "]"; else if (value instanceof float[]) return "[float[]: " + ((float[]) value).length + "]"; else if (value instanceof double[]) return "[double[]: " + ((double[]) value).length + "]"; else if (value instanceof boolean[]) return "[boolean[]: " + ((boolean[]) value).length + "]"; else return value.getClass().getName(); } public static boolean isArray(Object value) { if (value == null) return false; else if (value instanceof Object[]) return true; else if (value instanceof char[]) return true; else if (value instanceof byte[]) return true; else if (value instanceof short[]) return true; else if (value instanceof int[]) return true; else if (value instanceof long[]) return true; else if (value instanceof float[]) return true; else if (value instanceof double[]) return true; else if (value instanceof boolean[]) return true; else return false; } public static String getDebug(String message, Object value[]) { StringBuffer result = new StringBuffer(); if (value == null) result.append(getDebug(message, "null") + newline); result.append(getDebug(message, value.length)); final int max = 10; for (int i = 0; i < value.length && i < max; i++) result.append(getDebug("\t" + i, value[i]) + newline); if (value.length > max) result.append(getDebug("\t...") + newline); result.append(newline); return result.toString(); } public static String getDebug(Class fClass, Throwable e) { return getDebug(fClass == null ? "[Unknown]" : fClass.getName(), e); } public static void debug(Class fClass, Throwable e) { debug(fClass.getName(), e); } private static final SimpleDateFormat timestamp = new SimpleDateFormat( "yyyy-MM-dd kk:mm:ss:SSS"); public static void debug(String message, boolean value) { debug(message + " " + ((value) ? ("true") : ("false"))); } public static void debug(String message, byte v[]) { debug(getDebug(message, v)); } public static void debug(String message, char v[]) { debug(getDebug(message, v)); } public static void debug(String message, Calendar value) { DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); debug(message, (value == null) ? "null" : df.format(value.getTime())); } public static void debug(String message, Date value) { DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); debug(message, (value == null) ? "null" : df.format(value)); } public static void debug(String message, double value) { debug(message + ": " + (value)); } public static void debug(String message, File file) { debug(message + ": " + ((file == null) ? "null" : file.getPath())); } // public static void debug(String message, Object value) // { // debug("Unknown Object " + message + ": " // + ((value == null) ? "null" : value.toString())); // } // public static void debug(String message, ICC_Profile value) // { // debug("ICC_Profile " + message + ": " // + ((value == null) ? "null" : value.toString())); // if (value != null) // { // debug("\t getProfileClass: " // + byteQuadToString(value.getProfileClass())); // debug("\t getPCSType: " + byteQuadToString(value.getPCSType())); // debug("\t getColorSpaceType() : " // + byteQuadToString(value.getColorSpaceType())); // } // } public static void debug(String message, int value) { debug(message + ": " + (value)); } public static void debug(String message, int v[]) { debug(getDebug(message, v)); } public static void debug(String message, byte v[], int max) { debug(getDebug(message, v, max)); } public static void debug(String message, java.util.List v) { String suffix = " [" + counter++ + "]"; debug(message + " (" + v.size() + ")" + suffix); for (int i = 0; i < v.size(); i++) debug("\t" + v.get(i).toString() + suffix); debug(); } public static void debug(String message, long value) { debug(message + " " + Long.toString(value)); } // public static void debug(String prefix, Point p) // { // System.out.println(prefix + ": " // + ((p == null) ? "null" : (p.x + ", " + p.y))); // } // // public static void debug(String prefix, Rectangle r) // { // debug(getDebug(prefix, r)); // } public static void debug(String message, String value) { debug(message + " " + value); } public static void debug(String message, Throwable e) { debug(getDebug(message, e)); } public static void debug(Throwable e) { debug(getDebug(e)); } public static void debug(Throwable e, int value) { debug(getDebug(e, value)); } public static void dumpStack() { debug(getStackTrace(new Exception("Stack trace"), -1, 1)); } public static void dumpStack(int limit) { debug(getStackTrace(new Exception("Stack trace"), limit, 1)); } public static String getDebug(String message, Throwable e) { return message + newline + getDebug(e); } public static String getDebug(Throwable e) { return getDebug(e, -1); } public static String getDebug(Throwable e, int max) { StringBuffer result = new StringBuffer(); String datetime = timestamp.format(new Date()).toLowerCase(); result.append(newline); result.append("Throwable: " + ((e == null) ? "" : ("(" + e.getClass().getName() + ")")) + ":" + datetime + newline); result.append("Throwable: " + ((e == null) ? "null" : e.getLocalizedMessage()) + newline); result.append(newline); result.append(getStackTrace(e, max)); result.append("Caught here:" + newline); result.append(getStackTrace(new Exception(), max, 1)); // Debug.dumpStack(); result.append(newline); return result.toString(); } public static String getStackTrace(Throwable e) { return getStackTrace(e, -1); } public static String getStackTrace(Throwable e, int limit) { return getStackTrace(e, limit, 0); } public static String getStackTrace(Throwable e, int limit, int skip) { StringBuffer result = new StringBuffer(); if (e != null) { StackTraceElement stes[] = e.getStackTrace(); if (stes != null) { for (int i = skip; i < stes.length && (limit < 0 || i < limit); i++) { StackTraceElement ste = stes[i]; result.append("\tat " + ste.getClassName() + "." + ste.getMethodName() + "(" + ste.getFileName() + ":" + ste.getLineNumber() + ")" + newline); } if (limit >= 0 && stes.length > limit) result.append("\t..." + newline); } // e.printStackTrace(System.out); result.append(newline); } return result.toString(); } public static void debugByteQuad(String message, int i) { int alpha = (i >> 24) & 0xff; int red = (i >> 16) & 0xff; int green = (i >> 8) & 0xff; int blue = (i >> 0) & 0xff; System.out.println(message + ": " + "alpha: " + alpha + ", " + "red: " + red + ", " + "green: " + green + ", " + "blue: " + blue); } public static void debugIPQuad(String message, int i) { int b1 = (i >> 24) & 0xff; int b2 = (i >> 16) & 0xff; int b3 = (i >> 8) & 0xff; int b4 = (i >> 0) & 0xff; System.out.println(message + ": " + "b1: " + b1 + ", " + "b2: " + b2 + ", " + "b3: " + b3 + ", " + "b4: " + b4); } public static void debugIPQuad(String message, byte bytes[]) { System.out.print(message + ": "); if (bytes == null) System.out.print("null"); else { for (int i = 0; i < bytes.length; i++) { if (i > 0) System.out.print("."); System.out.print(0xff & bytes[i]); } } System.out.println(); } // public static String getDebug(String prefix, Dimension r) // { // String s_ar1 = "null"; // String s_ar2 = "null"; // // if (r != null) // { // double aspect_ratio = ((double) r.width) / ((double) r.height); // double aspect_ratio2 = 1.0 / aspect_ratio; // // s_ar1 = "" + aspect_ratio; // s_ar2 = "" + aspect_ratio2; // // if (s_ar1.length() > 7) // s_ar1 = s_ar1.substring(0, 7); // if (s_ar2.length() > 7) // s_ar2 = s_ar2.substring(0, 7); // } // // return (prefix + ": " // + ((r == null) ? "null" : (r.width + "x" + r.height)) // + " aspect_ratio: " + s_ar1 + " (" + s_ar2 + ")"); // } // public static void debug(String prefix, Dimension r) // { // debug(getDebug(prefix, r)); // } // // public static String getDebug(String prefix, Rectangle r) // { // String s_ar1 = "null"; // String s_ar2 = "null"; // // if (r != null) // { // double aspect_ratio = ((double) r.width) / ((double) r.height); // double aspect_ratio2 = 1.0 / aspect_ratio; // // s_ar1 = "" + aspect_ratio; // s_ar2 = "" + aspect_ratio2; // // if (s_ar1.length() > 7) // s_ar1 = s_ar1.substring(0, 7); // if (s_ar2.length() > 7) // s_ar2 = s_ar2.substring(0, 7); // } // // return (prefix // + ": " // + ((r == null) ? "null" : (r.x + "x" + r.y + "," + r.width // + "x" + r.height)) + " aspect_ratio: " + s_ar1 + " (" // + s_ar2 + ")"); // } // // public static String getDebug(String prefix, Point p) // { // return (prefix + ": " + ((p == null) ? "null" : (p.x + ", " + p.y))); // } public static void dump(String prefix, Object value) { if (value == null) debug(prefix, "null"); else if (value instanceof Object[]) { Object[] array = (Object[]) value; debug(prefix, array); for (int i = 0; i < array.length; i++) dump(prefix + "\t" + i + ": ", array[i]); } else if (value instanceof int[]) { int[] array = (int[]) value; debug(prefix, array); for (int i = 0; i < array.length; i++) debug(prefix + "\t" + i + ": ", array[i]); } else if (value instanceof char[]) { char[] array = (char[]) value; debug(prefix, "[" + new String(array) + "]"); } else if (value instanceof long[]) { long[] array = (long[]) value; debug(prefix, array); for (int i = 0; i < array.length; i++) debug(prefix + "\t" + i + ": ", array[i]); } else if (value instanceof boolean[]) { boolean[] array = (boolean[]) value; debug(prefix, array); for (int i = 0; i < array.length; i++) debug(prefix + "\t" + i + ": ", array[i]); } else if (value instanceof byte[]) { byte[] array = (byte[]) value; debug(prefix, array); for (int i = 0; i < array.length; i++) debug(prefix + "\t" + i + ": ", array[i]); } else if (value instanceof float[]) { float[] array = (float[]) value; debug(prefix, array); for (int i = 0; i < array.length; i++) debug(prefix + "\t" + i + ": ", array[i]); } else if (value instanceof byte[]) { double[] array = (double[]) value; debug(prefix, array); for (int i = 0; i < array.length; i++) debug(prefix + "\t" + i + ": ", array[i]); } else if (value instanceof java.util.List) { java.util.List list = (java.util.List) value; debug(prefix, "list"); for (int i = 0; i < list.size(); i++) dump(prefix + "\t" + "list: " + i + ": ", list.get(i)); } else if (value instanceof Map) { java.util.Map map = (java.util.Map) value; debug(prefix, "map"); ArrayList keys = new ArrayList(map.keySet()); Collections.sort(keys); for (int i = 0; i < keys.size(); i++) { Object key = keys.get(i); dump(prefix + "\t" + "map: " + key + " -> ", map.get(key)); } } // else if (value instanceof String) // debug(prefix, value); else { debug(prefix, value.toString()); debug(prefix + "\t", value.getClass().getName()); } } public static final void purgeMemory() { try { // Thread.sleep(50); System.runFinalization(); Thread.sleep(50); System.gc(); Thread.sleep(50); } catch (Throwable e) { Debug.debug(e); } } }
26.586359
78
0.583564
787e1a793473a7917779017b1a95bcf8fae8d954
1,280
package org.sheinbergon.needle.jna.linux.structure; import com.sun.jna.Structure; import java.util.List; public class CpuSet extends Structure { /** * sched.h derived CPU set-size constant. */ private static final int CPU_SETSIZE = 1024; /** * sched.h derived CPU bitmask size. */ private static final int NCPUBITS = Long.SIZE; /** * JNA structure 'bits' field. */ public long[] __bits = new long[CPU_SETSIZE / NCPUBITS]; /** * Instantiate this {@link Structure}, disable synchronization and alignment optimization. * * @see Structure#setAlignType(int) * @see Structure#setAutoSynch(boolean) */ public CpuSet() { setAlignType(ALIGN_NONE); setAutoSynch(true); } /** * @return JNA {@link Structure} field older. */ @Override protected List<String> getFieldOrder() { return List.of("__bits"); } /** * Get the size of the cpu-set bitmask in bytes. * * @return the size of the cpu-set bitmask in bytes */ public int bytes() { return Long.BYTES * __bits.length; } /** * Zero-fill the memory backing this {@link Structure}. */ public void zero() { this.clear(); } }
21.694915
94
0.596094
40cc288645034e04ef6443dcea213255b3fcfb8e
5,044
package pokemoncard; import java.util.ArrayList; import java.util.Random; public class Deck { ArrayList<Carta> deck; public Deck(){ deck = carregar(); } public void addCarta(Carta carta) { deck.add(carta); } public int getSize(){ return deck.size(); } public Carta retirar(){ int remove = new Random().nextInt(deck.size()); Carta ret = deck.get(remove); deck.remove(remove); return ret; } private ArrayList<Carta>carregar(){ ArrayList<Carta> deckp1 = new ArrayList<>(); Pokemon p0 = new Pokemon(Tipo.POKEMON, TipoElemento.RAIO, "PICACHU", 50, 30, 0); Pokemon p1 = new Pokemon(Tipo.POKEMON, TipoElemento.AGUA, "SQUARTLE", 30, 20, 0); Pokemon p2 = new Pokemon(Tipo.POKEMON, TipoElemento.TERRA, "ONYX", 70, 50, 0); Pokemon p3 = new Pokemon(Tipo.POKEMON, TipoElemento.FOGO, "CHARMANDER", 50, 30, 0); Pokemon p4 = new Pokemon(Tipo.POKEMON, TipoElemento.NORMAL, "SPEROW", 60, 40, 0); Pokemon p5 = new Pokemon(Tipo.POKEMON, TipoElemento.TERRA, "DIGLET", 40, 30, 0); Pokemon p6 = new Pokemon(Tipo.POKEMON, TipoElemento.AGUA, "DRATINI", 50, 60, 0); Pokemon p7 = new Pokemon(Tipo.POKEMON, TipoElemento.RAIO, "ZAPTOS", 80, 50, 0); Pokemon p8 = new Pokemon(Tipo.POKEMON, TipoElemento.NORMAL, "PINCHER", 60, 70, 0); Pokemon p9 = new Pokemon(Tipo.POKEMON, TipoElemento.FOGO, "PONYTA", 50, 45, 0); Pokemon p10 = new Pokemon(Tipo.POKEMON, TipoElemento.RAIO, "ELETROMINE", 50, 30, 0); Pokemon p11 = new Pokemon(Tipo.POKEMON, TipoElemento.AGUA, "PSYDUCK", 30, 20, 0); Pokemon p12 = new Pokemon(Tipo.POKEMON, TipoElemento.TERRA, "GEODUTE", 70, 50, 0); Pokemon p13 = new Pokemon(Tipo.POKEMON, TipoElemento.FOGO, "VULPIX", 50, 30, 0); Pokemon p14 = new Pokemon(Tipo.POKEMON, TipoElemento.NORMAL, "PIGET", 60, 40, 0); Pokemon p15 = new Pokemon(Tipo.POKEMON, TipoElemento.TERRA, "CUBONE", 40, 30, 0); Pokemon p16 = new Pokemon(Tipo.POKEMON, TipoElemento.AGUA, "KRABBY", 50, 60, 0); Pokemon p17 = new Pokemon(Tipo.POKEMON, TipoElemento.RAIO, "VOLTORB", 80, 50, 0); Pokemon p18 = new Pokemon(Tipo.POKEMON, TipoElemento.NORMAL, "MANKEY", 60, 70, 0); Pokemon p19 = new Pokemon(Tipo.POKEMON, TipoElemento.FOGO, "MAGMAR", 50, 45, 0); Energia en0 = new Energia(Tipo.ENERGIA, TipoElemento.TERRA); Energia en1 = new Energia(Tipo.ENERGIA, TipoElemento.FOGO); Energia en2 = new Energia(Tipo.ENERGIA, TipoElemento.AGUA); Energia en3 = new Energia(Tipo.ENERGIA, TipoElemento.RAIO); Energia en4 = new Energia(Tipo.ENERGIA, TipoElemento.TERRA); Energia en5 = new Energia(Tipo.ENERGIA, TipoElemento.FOGO); Energia en6 = new Energia(Tipo.ENERGIA, TipoElemento.AGUA); Energia en7 = new Energia(Tipo.ENERGIA, TipoElemento.RAIO); Energia en8 = new Energia(Tipo.ENERGIA, TipoElemento.TERRA); Energia en9 = new Energia(Tipo.ENERGIA, TipoElemento.FOGO); Energia en10 = new Energia(Tipo.ENERGIA, TipoElemento.AGUA); Energia en11 = new Energia(Tipo.ENERGIA, TipoElemento.RAIO); Energia en12 = new Energia(Tipo.ENERGIA, TipoElemento.TERRA); Energia en13 = new Energia(Tipo.ENERGIA, TipoElemento.FOGO); Energia en14 = new Energia(Tipo.ENERGIA, TipoElemento.AGUA); Energia en15 = new Energia(Tipo.ENERGIA, TipoElemento.RAIO); Treinador eq0 = new Treinador(Tipo.TREINADOR); Treinador eq1 = new Treinador(Tipo.TREINADOR); Treinador eq2 = new Treinador(Tipo.TREINADOR); Treinador eq3 = new Treinador(Tipo.TREINADOR); deckp1.add(p0); deckp1.add(p1); deckp1.add(p2); deckp1.add(p3); deckp1.add(p4); deckp1.add(p5); deckp1.add(p6); deckp1.add(p7); deckp1.add(p8); deckp1.add(p9); deckp1.add(p10); deckp1.add(p11); deckp1.add(p12); deckp1.add(p13); deckp1.add(p14); deckp1.add(p15); deckp1.add(p16); deckp1.add(p17); deckp1.add(p18); deckp1.add(p19); deckp1.add(en0); deckp1.add(en1); deckp1.add(en2); deckp1.add(en3); deckp1.add(en4); deckp1.add(en5); deckp1.add(en6); deckp1.add(en7); deckp1.add(en8); deckp1.add(en9); deckp1.add(en10); deckp1.add(en11); deckp1.add(en12); deckp1.add(en13); deckp1.add(en14); deckp1.add(en15); deckp1.add(eq0); deckp1.add(eq1); deckp1.add(eq2); deckp1.add(eq3); return deckp1; } @Override public String toString() { return "Deck{" + "deck=" + deck + '}'; } }
38.503817
93
0.587431
ea2c0f250124f56971880b133016657ed8ecfd1b
2,786
package com.eltechs.axs.container.impl; import com.eltechs.axs.container.annotations.PostAdd; import com.eltechs.axs.container.annotations.PreRemove; import com.eltechs.axs.helpers.Assert; import com.eltechs.axs.helpers.ReflectionHelpers; import com.eltechs.axs.helpers.ReflectionHelpers.Filters; import com.eltechs.axs.helpers.ReflectionHelpers.MethodCallback; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; public abstract class LifecycleHandlersScanner { private LifecycleHandlersScanner() { } public static List<LifecycleHandlerMethod> listPostAddActions(Class<?> cls) { final ArrayList arrayList = new ArrayList(); try { ReflectionHelpers.doWithMethods(cls, new MethodCallback() { public void apply(Method method) throws IllegalArgumentException, IllegalAccessException { boolean z = method.getParameterTypes().length != 0; Assert.isFalse(ReflectionHelpers.isStatic(method), String.format("The method %s is marked with @PostAdd annotation and must be a member method.", new Object[]{method})); Assert.isFalse(z, String.format("The method %s is marked with @PostAdd annotation and must have no parameters.", new Object[]{method})); method.setAccessible(true); arrayList.add(new LifecycleHandlerMethod(method)); } }, Filters.instanceMethodsBearingAnnotation(PostAdd.class)); } catch (IllegalAccessException unused) { Assert.unreachable(); } arrayList.trimToSize(); return arrayList; } public static List<LifecycleHandlerMethod> listPreRemoveActions(Class<?> cls) { final ArrayList arrayList = new ArrayList(); try { ReflectionHelpers.doWithMethods(cls, new MethodCallback() { public void apply(Method method) throws IllegalArgumentException, IllegalAccessException { boolean z = method.getParameterTypes().length != 0; Assert.isFalse(ReflectionHelpers.isStatic(method), String.format("The method %s is marked with @PreRemove annotation and must be a member method.", new Object[]{method})); Assert.isFalse(z, String.format("The method %s is marked with @PreRemove annotation and must have no parameters.", new Object[]{method})); method.setAccessible(true); arrayList.add(new LifecycleHandlerMethod(method)); } }, Filters.instanceMethodsBearingAnnotation(PreRemove.class)); } catch (IllegalAccessException unused) { Assert.unreachable(); } arrayList.trimToSize(); return arrayList; } }
50.654545
191
0.670854
4a3d9eb0f56c88e2e49f28dfaff638af17735ada
750
package Concurrent; /** * Project: LearnJava * Package: Concurrent * Author: Novemser * 2017/4/5 */ public class Profiler { private static final ThreadLocal<Long> TIME_THREADLOCAK = new ThreadLocal<Long>() { @Override protected Long initialValue() { return System.currentTimeMillis(); } }; public static void begin() { TIME_THREADLOCAK.set(System.currentTimeMillis()); } public static long end() { return System.currentTimeMillis() - TIME_THREADLOCAK.get(); } public static void main(String[] args) { Profiler.begin(); SleepUtils.second(1); System.out.println("Cost:" + Profiler.end() + " mills"); } }
24.193548
88
0.592
c2c104a82e6dce9d7994613f501168f05f3db123
2,778
package com.jeff.tianti.common.service; import java.io.Serializable; import java.util.Collection; import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import com.jeff.tianti.common.dao.CommonDao; /** * 基础Service的定义 * @author Jeff Xu * @since 2015-12-09 * @param <E> * @param <ID> */ public abstract class CommonService<E,ID extends Serializable> { protected CommonDao<E,ID> commonDao; public void setCommonDao(CommonDao<E, ID> commonDao) { this.commonDao = commonDao; } public CommonDao<E, ID> getCommonDao() { return commonDao; } /** * 根据ID获取某个Entity * @param id * @return */ public E get(ID id) { return commonDao.getOne(id); } /** * 根据ID查找某个Entity(建议使用) * @param id * @return */ public E find(ID id) { return commonDao.findOne(id); } /** * 获取所有的Entity列表 * @return */ public List<E> getAll() { return commonDao.findAll(); } /** * 获取Entity的总数 * @return */ public Long getTotalCount() { return commonDao.count(); } /** * 保存Entity * @param entity * @return */ public E save(E entity) { return commonDao.save(entity); } /** * 修改Entity * @param entity * @return */ public E update(E entity) { return commonDao.save(entity); } /** * 删除Entity * @param entity */ public void delete(E entity) { commonDao.delete(entity); } /** * 根据Id删除某个Entity * @param id */ public void delete(ID id) { commonDao.delete(id); } /** * 删除Entity的集合类 * @param entities */ public void delete(Collection<E> entities) { commonDao.delete(entities); } /** * 清空缓存,提交持久化 */ public void flush() { commonDao.flush(); } /** * 根据查询信息获取某个Entity的列表 * @param spec * @return */ public List<E> findAll(Specification<E> spec) { return commonDao.findAll(spec); } /** * 获取Entity的分页信息 * @param pageable * @return */ public Page<E> findAll(Pageable pageable){ return commonDao.findAll(pageable); } /** * 根据查询条件和分页信息获取某个结果的分页信息 * @param spec * @param pageable * @return */ public Page<E> findAll(Specification<E> spec, Pageable pageable) { return commonDao.findAll(spec, pageable); } /** * 根据查询条件和排序条件获取某个结果集列表 * @param spec * @param sort * @return */ public List<E> findAll(Specification<E> spec, Sort sort) { return commonDao.findAll(spec); } /** * 查询某个条件的结果数集 * @param spec * @return */ public long count(Specification<E> spec) { return commonDao.count(spec); } }
17.042945
68
0.613751
45d19112464c1e3aaf0139dfbf5c63e2a5dd1c5d
2,864
package com.ysy.session; import java.util.HashMap; import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; /** * 提供缓存api * * @author yaosiyuan * */ public class CacheManager { private Map<String, Cache> cacheMap = new HashMap<String, Cache>(); /** * * @description: TODO (添加session) * @author: yaosiyuan * @version: 2.0 * @date: 2019 2019年3月2日 下午1:10:23 * @param key * @param value */ public synchronized void put(String key, Object value) { put(key, value, null); } /** * * @description: TODO () * @author: yaosiyuan * @version: 2.0 * @date: 2019 2019年3月2日 下午1:10:05 * @param key * @param value * @param timeout */ public synchronized void put(String key, Object value, Long timeout) { Cache cache = new Cache(); cache.setKey(key); cache.setValue(value); if (timeout != null) { cache.setTimeout(System.currentTimeMillis() + timeout); } cacheMap.put(key, cache); } public synchronized void del(String key) { cacheMap.remove(key); } /** * * @description: TODO (使用key查询缓存) * @author: yaosiyuan * @version: 2.0 * @date: 2019 2019年3月2日 下午1:02:58 * @param key * @return */ public synchronized Object get(String key) { Cache cache = cacheMap.get(key); if (cache != null) { return cache.getValue(); } return null; } public synchronized void remove(String key) { System.out.println("key:" + key + "删除成功"); cacheMap.remove(key); } /** * * @description: TODO (定时检查删除) * @author: yaosiyuan * @version: 2.0 * @date: 2019 2019年3月2日 下午1:20:42 */ public synchronized void checkValidityData() { for (String key : cacheMap.keySet()) { Cache cache = cacheMap.get(key); if (cache == null) { break; } // 毫秒数 Long timeout = cache.getTimeout(); Long currentTimeMillis = System.currentTimeMillis(); // 说明已经过期 if ((currentTimeMillis - timeout) > 0) { remove(key); } } } /** * * * @description: TODO (主函数) * @author: yaosiyuan * @version: 2.0 * @date: 2019 2019年3月2日 下午1:09:38 * @param args * @throws InterruptedException */ public static void main(String[] args) throws InterruptedException { final CacheManager cacheManager = new CacheManager(); cacheManager.put("userName", "123", 5000l); System.out.println("保存成功"); // 定期检查刷新数据 ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(5); scheduledThreadPool.schedule(new Runnable() { public void run() { cacheManager.checkValidityData(); } }, 5000, TimeUnit.MILLISECONDS); try { Thread.sleep(5000); } catch (Exception e) { // TODO: handle exception } String userName = (String) cacheManager.get("userName"); System.out.println("username:" + userName); // 开启一个线程,检查有效期 } }
20.753623
85
0.654679
3c74b77c8f49b250eb198e48c667db22995e7e89
24,664
/* * Copyright (c) 2014, Regents of the University of California * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.uci.python.profiler; import java.math.*; import org.python.core.*; import com.oracle.truffle.api.CompilerDirectives.SlowPath; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.instrument.*; import com.oracle.truffle.api.nodes.*; import edu.uci.python.nodes.*; import edu.uci.python.runtime.*; import edu.uci.python.runtime.array.*; import edu.uci.python.runtime.builtin.*; import edu.uci.python.runtime.datatype.*; import edu.uci.python.runtime.datatype.PSlice.*; import edu.uci.python.runtime.function.*; import edu.uci.python.runtime.iterator.*; import edu.uci.python.runtime.object.*; import edu.uci.python.runtime.sequence.*; import edu.uci.python.runtime.standardtype.*; /** * @author Gulfem */ public class PythonWrapperNode extends PNode implements Wrapper { @Child protected PNode child; protected final Probe probe; public PythonWrapperNode(PythonContext context, PNode child) { /** * Don't insert the child here, because child node will be replaced with the wrapper node. * If child node is inserted here, it's parent (which will be wrapper's parent after * replacement) will be lost. Instead, wrapper is created, and the child is replaced with * its wrapper, and then wrapper's child is adopted by calling adoptChildren() in * {@link ProfilerTranslator}. */ this.child = child; /** * context.getProbe will either generate a probe for this source section, or return the * existing probe for this section. There can be only one probe for the same source section. */ this.probe = context.createProbe(child.getSourceSection()); } @Override public Object execute(VirtualFrame frame) { probe.enter(child, frame); Object result; try { result = child.execute(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public int executeInt(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); int result; try { result = child.executeInt(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public double executeDouble(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); double result; try { result = child.executeDouble(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public char executeCharacter(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); char result; try { result = child.executeCharacter(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public boolean executeBoolean(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); boolean result; try { result = child.executeBoolean(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public BigInteger executeBigInteger(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); BigInteger result; try { result = child.executeBigInteger(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public String executeString(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); String result; try { result = child.executeString(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PString executePString(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PString result; try { result = child.executePString(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PComplex executePComplex(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PComplex result; try { result = child.executePComplex(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PBytes executeBytes(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PBytes result; try { result = child.executeBytes(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PDict executePDictionary(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PDict result; try { result = child.executePDictionary(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PList executePList(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PList result; try { result = child.executePList(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PTuple executePTuple(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PTuple result; try { result = child.executePTuple(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PRange executePRange(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PRange result; try { result = child.executePRange(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PSequence executePSequence(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PSequence result; try { result = child.executePSequence(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PSet executePSet(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PSet result; try { result = child.executePSet(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PFrozenSet executePFrozenSet(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PFrozenSet result; try { result = child.executePFrozenSet(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PBaseSet executePBaseSet(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PBaseSet result; try { result = child.executePBaseSet(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PIntArray executePIntArray(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PIntArray result; try { result = child.executePIntArray(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PDoubleArray executePDoubleArray(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PDoubleArray result; try { result = child.executePDoubleArray(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PCharArray executePCharArray(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PCharArray result; try { result = child.executePCharArray(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PArray executePArray(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PArray result; try { result = child.executePArray(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PEnumerate executePEnumerate(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PEnumerate result; try { result = child.executePEnumerate(frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PZip executePZip(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PZip result; try { result = child.executePZip(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PStartSlice executePStartSlice(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PStartSlice result; try { result = child.executePStartSlice(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PStopSlice executePStopSlice(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PStopSlice result; try { result = child.executePStopSlice(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PSlice executePSlice(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PSlice result; try { result = child.executePSlice(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PGenerator executePGenerator(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PGenerator result; try { result = child.executePGenerator(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PDoubleIterator executePDoubleIterator(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PDoubleIterator result; try { result = child.executePDoubleIterator(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PIntegerIterator executePIntegerIterator(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PIntegerIterator result; try { result = child.executePIntegerIterator(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PIterator executePIterator(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PIterator result; try { result = child.executePIterator(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PIterable executePIterable(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PIterable result; try { result = child.executePIterable(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PNone executePNone(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PNone result; try { result = child.executePNone(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PythonBuiltinClass executePythonBuiltinClass(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PythonBuiltinClass result; try { result = child.executePythonBuiltinClass(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PythonBuiltinObject executePythonBuiltinObject(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PythonBuiltinObject result; try { result = child.executePythonBuiltinObject(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PythonModule executePythonModule(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PythonModule result; try { result = child.executePythonModule(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PythonClass executePythonClass(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PythonClass result; try { result = child.executePythonClass(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PythonObject executePythonObject(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PythonObject result; try { result = child.executePythonObject(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PyObject executePyObject(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PyObject result; try { result = child.executePyObject(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public Object[] executeObjectArray(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); Object[] result; try { result = child.executeObjectArray(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PRangeIterator executePRangeIterator(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PRangeIterator result; try { result = child.executePRangeIterator(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PIntegerSequenceIterator executePIntegerSequenceIterator(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PIntegerSequenceIterator result; try { result = child.executePIntegerSequenceIterator(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PSequenceIterator executePSequenceIterator(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PSequenceIterator result; try { result = child.executePSequenceIterator(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } @Override public PythonCallable executePythonCallable(VirtualFrame frame) throws UnexpectedResultException { probe.enter(child, frame); PythonCallable result; try { result = child.executePythonCallable(frame); probe.leave(child, frame); } catch (KillException e) { throw (e); } catch (Exception e) { probe.leaveExceptional(child, frame, e); throw (e); } return result; } public PNode getChild() { return child; } public Probe getProbe() { return probe; } @SlowPath public boolean isTaggedAs(SyntaxTag tag) { return probe.isTaggedAs(tag); } @SlowPath public Iterable<SyntaxTag> getSyntaxTags() { return probe.getSyntaxTags(); } }
27.900452
122
0.578617
b0415e7358815b7731bf5756c27751d616db8da0
833
package com.github.brane08.pagila.seedworks.beans; import com.github.brane08.pagila.seedworks.entities.PagedList; import java.io.Serializable; import java.util.List; public class ApiResult<T> implements Serializable { protected final boolean success; protected final T data; public ApiResult(boolean success, T data) { this.success = success; this.data = data; } public boolean isSuccess() { return success; } public T getData() { return data; } public static <R> ApiResult<R> single(R obj) { return new ApiResult<>(true, obj); } public static <R> ApiResult<List<R>> array(List<R> list, int totalCount) { return new PageResult<>(true, list, totalCount); } public static <R> ApiResult<List<R>> array(PagedList<R> paged) { return new PageResult<>(true, paged.getList(), paged.getTotalCount()); } }
22.513514
75
0.721489
c5435c5057e5029a33eddfb98ccb98bef80bc178
712
package redstoneparadox.packup.test; import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.util.registry.Registry; public class PackUpTests { private static Block TEST_ONE_BLOCK = new Block(FabricBlockSettings.copy(Blocks.DIRT).build()); private static BlockItem TEST_ONE_ITEM = new BlockItem(TEST_ONE_BLOCK, new Item.Settings()); public static void setup() { Registry.register(Registry.BLOCK, "packup:test_one_block", TEST_ONE_BLOCK); Registry.register(Registry.ITEM, "packup:test_one_item", TEST_ONE_ITEM); } }
35.6
99
0.77809
8d7f573295be3ee0b01d3842a9e1d3ca5de9dd4d
1,162
package net.runelite.client.plugins.soulwars; import javax.inject.Inject; import net.runelite.api.Client; import net.runelite.client.ui.overlay.*; import net.runelite.client.ui.overlay.components.LineComponent; import java.awt.*; public class AvatarOverlay extends OverlayPanel { private final SoulWarsPlugin plugin; private final SoulWarsConfig config; private final Client client; @Inject public AvatarOverlay(SoulWarsPlugin plugin, SoulWarsConfig config, Client client) { super(plugin); this.plugin = plugin; this.config = config; this.client = client; } public Dimension render(Graphics2D graphics) { this.panelComponent.getChildren().clear(); if(config.showAvatarDamage() && plugin.avatarDamage > 0 && plugin.isInSW() && this.client.getLocalPlayer() != null && this.client.getLocalPlayer().getTeam() > 0) { this.panelComponent.getChildren().add(LineComponent.builder() .left("Avatar DMG:") .right(String.valueOf(plugin.avatarDamage)) .build()); } return super.render(graphics); } }
32.277778
171
0.666093
614aa26f48526d6bfa398d30905ba400b8ae4120
98
package com.gof.example.creational.factory; public interface Developer { void writeCode(); }
16.333333
43
0.755102
1dbac114ba7291e521fcdcd632d68eedaabac7c7
406
package org.opensrp.dto; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import java.util.List; import java.util.Set; @Getter @Setter @NoArgsConstructor @AllArgsConstructor public class ExportImagesSummary { private List<ExportFlagProblemEventImageMetadata> exportFlagProblemEventImageMetadataList; private Set<String> servicePoints; }
20.3
92
0.839901
36160a7cb3b002d4fedc688d2987becafac006e9
919
// package com.taotao.cloud.sys.biz.service.impl; // // import com.taotao.cloud.data.mybatis.plus.service.impl.SuperServiceImpl; // import com.taotao.cloud.sys.biz.entity.SysUserRole; // import com.taotao.cloud.sys.biz.mapper.SysUserRoleMapper; // import com.taotao.cloud.sys.biz.service.ISysUserRoleService; // import org.springframework.stereotype.Service; // // import java.util.List; // // /** // * 用户角色表 服务实现类 // * // * @author shuigedeng // * @since 2020/4/30 11:42 // */ // @Service // public class SysUserRoleServiceImpl extends SuperServiceImpl<SysUserRoleMapper, SysUserRole> implements ISysUserRoleService { // // // @Override // public boolean save(SysUserRole entity) { // return super.save(entity); // } // // // @Override // public List<SysUserRole> selectUserRoleListByUserId(Long userId) { // return baseMapper.selectUserRoleListByUserId(userId); // } // }
28.71875
128
0.697497
91c167d3f2276932b850293f28df70370efef1b6
357
package com.yongj.exceptions; /** * Exception indicating the file extension with same name exists already * * @author yongjie.zhuang */ public class DuplicateExtException extends IllegalArgumentException { public DuplicateExtException(String e) { super(e); } public DuplicateExtException(Throwable t) { super(t); } }
18.789474
72
0.70028
73bdafb09a3493462278146bf3bbbccecfe534d3
2,252
package com.shupro.oa.mydemo.collection.example; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.TreeSet; /* * 模拟斗地主洗牌和发牌并对牌进行排序 * 思路: * A:创建一个HashMap集合 * B:创建一个ArrayList集合 * C:创建花色数组和点数数组 * D:从0开始往HashMap里面存储编号,并存储对应的牌 * 同时往ArrayList里面存储编号即可。 * E:洗牌(洗的是编号) * F:发牌(发的也是编号,为了保证编号是排序的,就创建TreeSet集合接收) * G:看牌(遍历TreeSet集合,获取编号,到HashMap集合找对应的牌) */ public class PokerDemo { public static void main(String[] args) { // 创建一个HashMap集合 HashMap<Integer, String> hm = new HashMap<Integer, String>(); // 创建一个ArrayList集合 ArrayList<Integer> array = new ArrayList<Integer>(); // 创建花色数组和点数数组 // 定义一个花色数组 String[] colors = { "♠", "♥", "♣", "♦" }; // 定义一个点数数组 String[] numbers = { "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2", }; // 从0开始往HashMap里面存储编号,并存储对应的牌,同时往ArrayList里面存储编号即可。 int index = 0; for (String number : numbers) { for (String color : colors) { String poker = color.concat(number); hm.put(index, poker); array.add(index); index++; } } hm.put(index, "小王"); array.add(index); index++; hm.put(index, "大王"); array.add(index); // 洗牌(洗的是编号) Collections.shuffle(array); // 发牌(发的也是编号,为了保证编号是排序的,就创建TreeSet集合接收) TreeSet<Integer> fengQingYang = new TreeSet<Integer>(); TreeSet<Integer> linQingXia = new TreeSet<Integer>(); TreeSet<Integer> liuYi = new TreeSet<Integer>(); TreeSet<Integer> diPai = new TreeSet<Integer>(); for (int x = 0; x < array.size(); x++) { if (x >= array.size() - 3) { diPai.add(array.get(x)); } else if (x % 3 == 0) { fengQingYang.add(array.get(x)); } else if (x % 3 == 1) { linQingXia.add(array.get(x)); } else if (x % 3 == 2) { liuYi.add(array.get(x)); } } // 看牌(遍历TreeSet集合,获取编号,到HashMap集合找对应的牌) lookPoker("风清扬", fengQingYang, hm); lookPoker("林青霞", linQingXia, hm); lookPoker("刘意", liuYi, hm); lookPoker("底牌", diPai, hm); } // 写看牌的功能 public static void lookPoker(String name, TreeSet<Integer> ts, HashMap<Integer, String> hm) { System.out.print(name + "的牌是:"); for (Integer key : ts) { String value = hm.get(key); System.out.print(value + " "); } System.out.println(); } }
24.747253
73
0.620337
58b835e898630d7d6bfa3d845b615a42745c8eb8
3,511
/* * Licensed by the author of Time4J-project. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. The copyright owner * 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 net.time4j.calendar.astro; /** * <p>Enumeration of various twilight definitions. </p> * * <p>See also <a href="https://en.wikipedia.org/wiki/Twilight">Wikipedia</a>. </p> * * @author Meno Hochschild * @since 3.34/4.29 */ /*[deutsch] * <p>Aufz&auml;hlung verschiedener D&auml;mmerungsdefinitionen. </p> * * <p>Siehe auch <a href="https://en.wikipedia.org/wiki/Twilight">Wikipedia</a>. </p> * * @author Meno Hochschild * @since 3.34/4.29 */ public enum Twilight { //~ Statische Felder/Initialisierungen -------------------------------- /** * <p>Marks the time when the sun is 4 degrees below the horizon. </p> * * <p>Mainly used by photographers. There is no official definition but usually photographers * talk about the blue hour when the sun is between 4 and eight degrees below the horizon. * See also <a href="https://en.wikipedia.org/wiki/Blue_hour">Wikipedia</a>. </p> */ /*[deutsch] * <p>Markiert die Zeit, wenn die Sonne 4 Grad unter dem Horizont ist. </p> * * <p>Haupts&auml;chlich von Fotografen verwendet. Es gibt keine offizielle Definition, aber * normalerweise sprechen Fotografen von der blauen Stunden, wenn die Sonne zwischen 4 und 8 Grad * unter dem Horizont steht. Siehe auch <a href="https://en.wikipedia.org/wiki/Blue_hour">Wikipedia</a>. </p> */ BLUE_HOUR(4.0), /** * <p>Marks the time when the sun is 6 degrees below the horizon. </p> */ /*[deutsch] * <p>Markiert die Zeit, wenn die Sonne 6 Grad unter dem Horizont ist. </p> */ CIVIL(6.0), /** * <p>Marks the time when the sun is 12 degrees below the horizon. </p> */ /*[deutsch] * <p>Markiert die Zeit, wenn die Sonne 12 Grad unter dem Horizont ist. </p> */ NAUTICAL(12.0), /** * <p>Marks the time when the sun is 18 degrees below the horizon. </p> * * <p>Is the sun even deeper below the horizon then people talk about night. </p> */ /*[deutsch] * <p>Markiert die Zeit, wenn die Sonne 18 Grad unter dem Horizont ist. </p> * * <p>Steht die Sonne noch tiefer, spricht man von tiefer Nacht. </p> */ ASTRONOMICAL(18.0); //~ Instanzvariablen -------------------------------------------------- private transient final double angle; //~ Konstruktoren ----------------------------------------------------- private Twilight(double angle) { this.angle = angle; } //~ Methoden ---------------------------------------------------------- /** * <p>Obtains the associated angle of the sun relative to the horizon in degrees. </p> * * @return angle in degrees */ /*[deutsch] * <p>Liefert den assozierten Winkel in Grad, unter dem die Sonne relativ zum Horizont erscheint. </p> * * @return angle in degrees */ double getAngle() { return this.angle; } }
30.267241
110
0.647964
44c1eb84b91585fc7f1609d433f5c340b4b2ecf5
3,523
/* * Copyright 2016 Red Hat, Inc. and/or its affiliates. * * 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.kie.workbench.common.screens.server.management.client; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.event.Observes; import javax.inject.Inject; import org.kie.workbench.common.screens.server.management.client.events.AddNewContainer; import org.kie.workbench.common.screens.server.management.client.events.AddNewServerTemplate; import org.kie.workbench.common.screens.server.management.client.wizard.NewContainerWizard; import org.kie.workbench.common.screens.server.management.client.wizard.NewServerTemplateWizard; import org.slf4j.Logger; import org.uberfire.client.annotations.Perspective; import org.uberfire.client.annotations.WorkbenchPerspective; import org.uberfire.client.workbench.panels.impl.StaticWorkbenchPanelPresenter; import org.uberfire.mvp.impl.DefaultPlaceRequest; import org.uberfire.workbench.model.PerspectiveDefinition; import org.uberfire.workbench.model.impl.PartDefinitionImpl; import org.uberfire.workbench.model.impl.PerspectiveDefinitionImpl; @ApplicationScoped @WorkbenchPerspective(identifier = "ServerManagementPerspective") public class ServerManagementPerspective { private final Logger logger; private final NewServerTemplateWizard newServerTemplateWizard; private final NewContainerWizard newContainerWizard; @Inject public ServerManagementPerspective( final Logger logger, final NewServerTemplateWizard newServerTemplateWizard, final NewContainerWizard newContainerWizard ) { this.logger = logger; this.newServerTemplateWizard = newServerTemplateWizard; this.newContainerWizard = newContainerWizard; } @Perspective public PerspectiveDefinition buildPerspective() { final PerspectiveDefinition perspective = new PerspectiveDefinitionImpl( StaticWorkbenchPanelPresenter.class.getName() ); perspective.setName( "ServerManagementPerspective" ); perspective.getRoot().addPart( new PartDefinitionImpl( new DefaultPlaceRequest( "ServerManagementBrowser" ) ) ); return perspective; } public void onNewTemplate( @Observes final AddNewServerTemplate addNewServerTemplate ) { if ( addNewServerTemplate != null ) { newServerTemplateWizard.clear(); newServerTemplateWizard.start(); } else { logger.warn( "Illegal event argument." ); } } public void onNewContainer( @Observes final AddNewContainer addNewContainer ) { if ( addNewContainer != null && addNewContainer.getServerTemplate() != null ) { newContainerWizard.clear(); newContainerWizard.setServerTemplate( addNewContainer.getServerTemplate() ); newContainerWizard.start(); } else { logger.warn( "Illegal event argument." ); } } }
41.940476
129
0.740562
c149afc29c3e982ad211debf3ab30619cc7424b0
384
package mirror.android.view; import mirror.MethodReflectParams; import mirror.RefClass; import mirror.RefMethod; public class CompatibilityInfoHolder { public static Class<?> Class = RefClass.load(CompatibilityInfoHolder.class, "android.view.CompatibilityInfoHolder"); @MethodReflectParams({"android.content.res.CompatibilityInfo"}) public static RefMethod<Void> set; }
32
120
0.799479
2d4313bd5622430a071df0a55016288babb02a8a
3,326
package com.avaje.ebeaninternal.server.lib.sql; import java.util.logging.Level; import java.util.logging.Logger; import com.avaje.ebean.config.GlobalProperties; import com.avaje.ebeaninternal.server.lib.util.MailEvent; import com.avaje.ebeaninternal.server.lib.util.MailListener; import com.avaje.ebeaninternal.server.lib.util.MailMessage; import com.avaje.ebeaninternal.server.lib.util.MailSender; /** * A simple smtp email alert that sends a email message * on dataSourceDown and dataSourceUp etc. * <ul> * <li>alert.fromuser = the from user name * <li>alert.fromemail = the from email account * <li>alert.toemail = comma delimited list of email accounts to email * <li>alert.mailserver = the smpt server name * </ul> */ public class SimpleAlerter implements DataSourceAlertListener, MailListener { private static final Logger logger = Logger.getLogger(SimpleAlerter.class.getName()); //boolean sendInBackGround = true; /** * Create a SimpleAlerter. */ public SimpleAlerter() { } /** * If the email failed then log the error. */ public void handleEvent(MailEvent event) { Throwable e = event.getError(); if (e != null){ logger.log(Level.SEVERE, null, e); } } /** * Send the dataSource down alert. */ public void dataSourceDown(String dataSourceName) { String msg = getSubject(true, dataSourceName); sendMessage(msg, msg); } /** * Send the dataSource up alert. */ public void dataSourceUp(String dataSourceName) { String msg = getSubject(false, dataSourceName); sendMessage(msg, msg); } /** * Send the warning message. */ public void warning(String subject, String msg) { sendMessage(subject, msg); } private String getSubject(boolean isDown, String dsName) { String msg = "The DataSource "+dsName; if (isDown){ msg += " is DOWN!!"; } else { msg += " is UP."; } return msg; } private void sendMessage(String subject, String msg){ String fromUser = GlobalProperties.get("alert.fromuser", null); String fromEmail = GlobalProperties.get("alert.fromemail", null); String mailServerName = GlobalProperties.get("alert.mailserver", null); String toEmail = GlobalProperties.get("alert.toemail", null); if (mailServerName == null){ //throw new RuntimeException("alert.mailserver not set..."); return; } MailMessage data = new MailMessage(); data.setSender(fromUser, fromEmail); data.addBodyLine(msg); data.setSubject(subject); String[] toList = toEmail.split(","); if (toList.length==0) { throw new RuntimeException("alert.toemail has not been set?"); } for (int i = 0; i < toList.length; i++) { data.addRecipient(null, toList[i].trim()); } MailSender sender = new MailSender(mailServerName); sender.setMailListener(this); sender.sendInBackground(data); } }
30.513761
87
0.598617
4c6b210ba75d8ddf2298310190e3e14178b0d55d
1,623
package com.alpha.module_common.service; import android.content.Context; import com.alpha.module_common.Constants; import com.alpha.module_common.okhttp.OkHttpUtils; import java.util.HashMap; import retrofit2.Retrofit; import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; import retrofit2.converter.fastjson.FastJsonConverterFactory; import rx.Observable; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; public abstract class RetrofitManager { protected Retrofit retrofit; protected IApiService apiService; /** * 构造方法 */ public RetrofitManager(Context context) { retrofit = new Retrofit.Builder() .client(OkHttpUtils.getInstance(context).getOkHttpClient()) .addConverterFactory(FastJsonConverterFactory.create()) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .baseUrl(Constants.DOMAIN) .build(); //初始化接口类 apiService = retrofit.create(IApiService.class); } /** * 获取处理后的RequestParams对象 * @return */ public HashMap getRequestParams(){ HashMap params = new HashMap(); params.put("app_id", "2016789168"); params.put("model", "android"); params.put("version", "1.0"); return params; } public void toSubscribe(Observable observable, rx.Subscriber subscriber){ observable.subscribeOn(Schedulers.io()) .unsubscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(subscriber); } }
27.982759
77
0.671596
d0063e9f4e0a44537b5fd01743bee4fef7464e1d
1,861
package nxt.connection; import nxt.object.DataFieldType; /** * Stellt ein Datenfeld, welches vom PC geupdatet werden soll dar * @author Simon */ public class NxtDataField{ private String name; private DataFieldType type; private Object value; /** * Nicht manuell instanzieren! */ @Deprecated public NxtDataField(String name, DataFieldType type, String value){ this.name = name; this.type = type; switch(type){ case STRING: this.value = (String) value; break; case INTEGER: this.value = Integer.parseInt(value); break; case LONG: this.value = Long.parseLong(value); break; case DOUBLE: this.value = Double.parseDouble(value); break; case FLOAT: this.value = Float.parseFloat(value); break; case BOOLEAN: this.value = Boolean.parseBoolean(value); break; default: break; } } /** * Nicht manuell instanzieren! */ public NxtDataField(String name, DataFieldType type, Object value){ this.name = name; this.type = type; this.value = value; } /** * Gibt den Namen dieses Datenfeldes zurück * @return den Namen des Datenfeldes */ public String getName(){ return name; } /** * Gibt den Datenfeldtyp dieses Datenfeldes zurück * @return den Datenfeldtyp {String, Integer, Long, Double, Float} */ public DataFieldType getType(){ return type; } /** * Gibt den Datenfeldwert als Objekt zurück. Der tatsächliche Wert kann mithilfe von * explizitem casten ermittelt werden. Beispiel:<br> * <code>Object datafield = getValue();<br> * if(datafield instanceof String){<br> * String result = (String) datafield;<br> * }<br></code> * usw... * @return den Datenfeldwert als Objekt */ public Object getValue(){ return value; } }
21.639535
86
0.640516
437f9c67da96966f9dfdd1754beddcc2fbb81747
2,969
package javassist.convert; import javassist.bytecode.Descriptor; import javassist.bytecode.StackMap; import javassist.bytecode.StackMapTable; import javassist.CannotCompileException; import javassist.bytecode.CodeIterator; import javassist.CtClass; import javassist.bytecode.CodeAttribute; import javassist.bytecode.ConstPool; public final class TransformNew extends Transformer { private int nested; private String classname; private String trapClass; private String trapMethod; public TransformNew(final Transformer a1, final String a2, final String a3, final String a4) { super(a1); this.classname = a2; this.trapClass = a3; this.trapMethod = a4; } @Override public void initialize(final ConstPool a1, final CodeAttribute a2) { /*SL:36*/this.nested = 0; } @Override public int transform(final CtClass v-5, final int v-4, final CodeIterator v-3, final ConstPool v-2) throws CannotCompileException { final int v0 = /*EL:55*/v-3.byteAt(v-4); /*SL:56*/if (v0 == 187) { int a3 = /*EL:57*/v-3.u16bitAt(v-4 + 1); /*SL:58*/if (v-2.getClassInfo(a3).equals(this.classname)) { /*SL:59*/if (v-3.byteAt(v-4 + 3) != 89) { /*SL:60*/throw new CannotCompileException("NEW followed by no DUP was found"); } /*SL:63*/v-3.writeByte(0, v-4); /*SL:64*/v-3.writeByte(0, v-4 + 1); /*SL:65*/v-3.writeByte(0, v-4 + 2); /*SL:66*/v-3.writeByte(0, v-4 + 3); /*SL:67*/++this.nested; final StackMapTable a2 = /*EL:69*/(StackMapTable)v-3.get().getAttribute(/*EL:70*/"StackMapTable"); /*SL:71*/if (a2 != null) { /*SL:72*/a2.removeNew(v-4); } /*SL:75*/a3 = (StackMap)v-3.get().getAttribute("StackMap"); /*SL:76*/if (a3 != null) { /*SL:77*/a3.removeNew(v-4); } } } else/*SL:80*/ if (v0 == 183) { final int u16bit = /*EL:81*/v-3.u16bitAt(v-4 + 1); final int v = /*EL:82*/v-2.isConstructor(this.classname, u16bit); /*SL:83*/if (v != 0 && this.nested > 0) { final int a4 = /*EL:84*/this.computeMethodref(v, v-2); /*SL:85*/v-3.writeByte(184, v-4); /*SL:86*/v-3.write16bit(a4, v-4 + 1); /*SL:87*/--this.nested; } } /*SL:91*/return v-4; } private int computeMethodref(int a1, final ConstPool a2) { final int v1 = /*EL:95*/a2.addClassInfo(this.trapClass); final int v2 = /*EL:96*/a2.addUtf8Info(this.trapMethod); /*SL:97*/a1 = a2.addUtf8Info(/*EL:98*/Descriptor.changeReturnType(this.classname, a2.getUtf8Info(a1))); /*SL:100*/return a2.addMethodrefInfo(v1, a2.addNameAndTypeInfo(v2, a1)); } }
39.586667
135
0.554059
7c81cf64a35549ff13cd489f14e09efb878e9beb
11,527
/** * This class was created by <WireSegal>. It's distributed as * part of the Quark Mod. Get the Source Code in github: * https://github.com/Vazkii/Quark * <p> * Quark is Open Source and distributed under the * CC-BY-NC-SA 3.0 License: https://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB * <p> * File Created @ [Jul 15, 2019, 05:46 AM (EST)] */ package vazkii.quark.automation.block; import net.minecraft.block.*; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockFaceShape; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import vazkii.arl.block.BlockMod; import vazkii.arl.interf.IBlockColorProvider; import vazkii.quark.automation.tile.TileInductor; import vazkii.quark.base.block.IQuarkBlock; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Random; public class BlockRedstoneInductor extends BlockMod implements IQuarkBlock, IBlockColorProvider { protected static final AxisAlignedBB REDSTONE_DIODE_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.125D, 1.0D); public static final PropertyDirection FACING = BlockHorizontal.FACING; public static final PropertyBool POWERED = PropertyBool.create("powered"); public static final PropertyBool LOCKED = PropertyBool.create("locked"); public static final PropertyInteger POWER = PropertyInteger.create("power", 0, 15); public BlockRedstoneInductor() { super("redstone_inductor", Material.CIRCUITS); setDefaultState(blockState.getBaseState() .withProperty(FACING, EnumFacing.NORTH) .withProperty(POWERED, false) .withProperty(LOCKED, false)); setCreativeTab(CreativeTabs.REDSTONE); setSoundType(SoundType.WOOD); } @Override @SideOnly(Side.CLIENT) public IBlockColor getBlockColor() { return (state, worldIn, pos, tintIndex) -> tintIndex == 1 ? BlockRedstoneWire.colorMultiplier(state.getValue(POWER)) : -1; } @Override public IProperty[] getIgnoredProperties() { return new IProperty[] { POWER }; } @Override public IItemColor getItemColor() { return null; } @Override public boolean hasTileEntity(IBlockState state) { return true; } @Nullable @Override public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { return new TileInductor(); } @Nonnull @Override @SuppressWarnings("deprecation") public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) { return state.withProperty(POWER, getActiveSignal(worldIn, pos)); } private boolean shouldBeLocked(World worldIn, BlockPos pos, IBlockState state) { EnumFacing direction = state.getValue(FACING); EnumFacing side1 = direction.rotateY(); EnumFacing side2 = direction.rotateYCCW(); return this.getLockingPowerOnSide(worldIn, pos.offset(direction), direction) > 0 || this.getLockingPowerOnSide(worldIn, pos.offset(side1), side1) > 0 || this.getLockingPowerOnSide(worldIn, pos.offset(side2), side2) > 0; } protected int getLockingPowerOnSide(IBlockAccess worldIn, BlockPos pos, EnumFacing side) { IBlockState iblockstate = worldIn.getBlockState(pos); if (BlockRedstoneRepeater.isDiode(iblockstate)) return worldIn.getStrongPower(pos, side); else return 0; } @Override public void randomTick(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Random random) { // NO-OP } @Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { boolean isLocked = isLocked(state); boolean willBeLocked = shouldBeLocked(worldIn, pos, state); EnumFacing side = state.getValue(FACING); IBlockState finalState = state.withProperty(LOCKED, willBeLocked); if (!isLocked || !willBeLocked) { int power = this.calculateInputStrength(worldIn, pos, state); TileEntity tile = worldIn.getTileEntity(pos); int prev = 0; if (tile instanceof TileInductor) { TileInductor inductor = (TileInductor) tile; prev = inductor.getOutputSignal(); inductor.setOutputSignal(power); } state = state.withProperty(POWER, power); finalState = finalState.withProperty(POWER, power); if (prev != power) { boolean shouldBePowered = this.shouldBePowered(worldIn, pos, state); boolean isPowered = this.isPowered(state); if (isPowered && !shouldBePowered) { finalState = finalState.withProperty(POWERED, false); } else if (!isPowered && shouldBePowered) { finalState = finalState.withProperty(POWERED, true); } } } worldIn.setBlockState(pos, finalState, 3); worldIn.notifyNeighborsOfStateExcept(pos.offset(side, -1), this, side); } protected int getActiveSignal(IBlockAccess world, BlockPos pos) { TileEntity tile = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); return tile instanceof TileInductor ? ((TileInductor)tile).getOutputSignal() : 0; } protected void updateState(World world, BlockPos pos) { world.scheduleBlockUpdate(pos, this, 1, -1); } @Nonnull @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, FACING, POWERED, LOCKED, POWER); } @Override public int getMetaFromState(IBlockState state) { return (state.getValue(FACING).getHorizontalIndex()) + (state.getValue(POWERED) ? 0b0100 : 0) + (state.getValue(LOCKED) ? 0b1000 : 0); } @Nonnull @Override @SuppressWarnings("deprecation") public IBlockState getStateFromMeta(int meta) { EnumFacing face = EnumFacing.byHorizontalIndex(meta & 0b0011); boolean powered = (meta & 0b0100) != 0; boolean locked = (meta & 0b1000) != 0; return getDefaultState().withProperty(FACING, face).withProperty(POWERED, powered).withProperty(LOCKED, locked); } @Nonnull @Override @SuppressWarnings("deprecation") public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return REDSTONE_DIODE_AABB; } @Override @SuppressWarnings("deprecation") public boolean isFullCube(IBlockState state) { return false; } @Override public boolean canPlaceBlockAt(World worldIn, @Nonnull BlockPos pos) { return worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) && super.canPlaceBlockAt(worldIn, pos); } public boolean canBlockStay(World worldIn, BlockPos pos) { return worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP); } protected boolean isLocked(IBlockState state) { return state.getValue(LOCKED); } protected boolean isPowered(IBlockState state) { return state.getValue(POWERED); } @Override @SuppressWarnings("deprecation") public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { return blockState.getWeakPower(blockAccess, pos, side); } @Override @SuppressWarnings("deprecation") public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { if(!isPowered(blockState)) return 0; else return blockState.getValue(FACING) == side ? getActiveSignal(blockAccess, pos) : 0; } @Override public boolean getWeakChanges(IBlockAccess world, BlockPos pos) { return true; } @Override @SuppressWarnings("deprecation") public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { if(canBlockStay(worldIn, pos)) updateState(worldIn, pos); else { dropBlockAsItem(worldIn, pos, state, 0); worldIn.setBlockToAir(pos); for(EnumFacing enumfacing : EnumFacing.values()) worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing), this, false); } } protected int calculateInputStrength(World worldIn, BlockPos pos, IBlockState state) { EnumFacing direction = state.getValue(FACING); EnumFacing side1 = direction.rotateY(); EnumFacing side2 = direction.rotateYCCW(); return Math.min(15, calculateInputStrength(worldIn, pos, direction) + calculateInputStrength(worldIn, pos, side1) + calculateInputStrength(worldIn, pos, side2)); } protected int calculateInputStrength(World worldIn, BlockPos pos, EnumFacing side) { BlockPos blockpos = pos.offset(side); IBlockState state = worldIn.getBlockState(blockpos); if (BlockRedstoneRepeater.isDiode(state)) return 0; int i = worldIn.getRedstonePower(blockpos, side); if(i >= 15) return i; else return Math.max(i, state.getBlock() == Blocks.REDSTONE_WIRE ? state.getValue(BlockRedstoneWire.POWER) : 0); } protected boolean shouldBePowered(World world, BlockPos pos, IBlockState currState) { return calculateInputStrength(world, pos, currState) > 0; } @Override @SuppressWarnings("deprecation") public boolean canProvidePower(IBlockState state) { return true; } @Nonnull @Override @SuppressWarnings("deprecation") public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { if(shouldBePowered(worldIn, pos, state)) worldIn.scheduleUpdate(pos, this, 1); } @Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { BlockRedstoneRandomizer.notify(this, worldIn, pos, state); } @Override public void breakBlock(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state) { super.breakBlock(worldIn, pos, state); BlockRedstoneRandomizer.notify(this, worldIn, pos, state); } @Override @SuppressWarnings("deprecation") public boolean isOpaqueCube(IBlockState state) { return false; } @Override public boolean rotateBlock(World world, @Nonnull BlockPos pos, @Nonnull EnumFacing axis) { if(super.rotateBlock(world, pos, axis)) { IBlockState state = world.getBlockState(pos); state = state.withProperty(POWERED, false); world.setBlockState(pos, state); world.scheduleUpdate(pos, this, 1); return true; } return false; } @Nonnull @Override @SuppressWarnings("deprecation") public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { return face == EnumFacing.DOWN ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED; } @Nonnull @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT; } }
33.123563
163
0.764032
a11f9c90ea0ff9b714d88457f3ea4d5a07168533
4,198
/* * Copyright 2021 Couchbase, 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.couchbase.connect.kafka.handler.sink; import com.couchbase.client.core.error.DocumentNotFoundException; import com.couchbase.client.java.ReactiveCollection; import com.couchbase.client.java.codec.RawJsonTranscoder; import com.couchbase.client.java.kv.RemoveOptions; import com.couchbase.client.java.kv.UpsertOptions; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import static com.couchbase.client.java.kv.RemoveOptions.removeOptions; import static com.couchbase.client.java.kv.UpsertOptions.upsertOptions; import static java.util.Objects.requireNonNull; /** * Holds a reactive publisher ({@link Mono} or {@link Flux}) * representing some completable action, and a concurrency hint * to ensure actions affecting the same document(s) are * never executed concurrently. */ public class SinkAction { private static final SinkAction IGNORE = new SinkAction(Mono.empty(), ConcurrencyHint.alwaysConcurrent()); private final Mono<Void> action; private final ConcurrencyHint concurrencyHint; /** * Returns a "no-op" action that ignores the message. */ public static SinkAction ignore() { return IGNORE; } /** * Returns an action that removes the document from Couchbase if it exists. * Uses the document ID as the concurrency hint. */ public static SinkAction remove(SinkHandlerParams params, ReactiveCollection collection, String documentId) { RemoveOptions options = removeOptions(); params.configureDurability(options); Mono<?> action = collection .remove(documentId, options) .onErrorResume(DocumentNotFoundException.class, throwable -> Mono.empty()); return new SinkAction(action, ConcurrencyHint.of(documentId)); } /** * Returns an action that upserts a JSON document to Couchbase. * Uses the document ID as the concurrency hint. * * @param params conveys expiry and durability settings * @param collection the collection where the document should be upserted. * @param documentId ID to use for the Couchbase document * @param json document content to upsert */ public static SinkAction upsertJson(SinkHandlerParams params, ReactiveCollection collection, String documentId, byte[] json) { UpsertOptions options = upsertOptions() .transcoder(RawJsonTranscoder.INSTANCE); params.configureDurability(options); params.expiry().ifPresent(options::expiry); Mono<?> action = collection.upsert(documentId, json, options); return new SinkAction(action, ConcurrencyHint.of(documentId)); } /** * Creates a custom sink action. * * @param action A cold publisher (Mono or Flux) encapsulating the work to be performed. * Any values emitted by the publisher are ignored; only the completion signal is used. * @param concurrencyHint Determines which actions may be performed concurrently. * Typically holds the ID of the Couchbase document modified by the action * (or {@link ConcurrencyHint#neverConcurrent()} if the affected documents are not known * in advance). This allows different documents to be updated concurrently, while ensuring * updates to the same document are executed sequentially. */ @SuppressWarnings("unchecked") public SinkAction(Publisher<?> action, ConcurrencyHint concurrencyHint) { this.action = (Mono<Void>) Mono.ignoreElements(action); this.concurrencyHint = requireNonNull(concurrencyHint); } public Mono<Void> action() { return action; } public ConcurrencyHint concurrencyHint() { return concurrencyHint; } }
38.513761
128
0.753216
51f50bec01626793a692ec19ef2bb2e4153cccff
5,340
package engine.evaluator.bet; import engine.bet.Bet; import engine.dealer.Card; import engine.hand.ClassifiedHand; import engine.hand.HandOutcome; import engine.hand.PlayerHand; import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; import static org.junit.jupiter.api.Assertions.*; class BetEvaluatorTest { @Test void testWinnerLoser() { List<Bet> bets = new ArrayList<>(); Bet b1 = new Bet(10); ClassifiedHand c1 = new ClassifiedHand("Foo", 1, 10); b1.getHand().classifyHand(c1); b1.getHand().setLoser(false); Bet b2 = new Bet(10); ClassifiedHand c2 = new ClassifiedHand("Foo", 5, 10); b2.getHand().setLoser(true); b2.getHand().classifyHand(c2); BetEvaluator myBetEvaluator = new BetEvaluator(); myBetEvaluator.evaluateBets(List.of(b1,b2)); assertEquals(b1.getHand().getOutcome(), HandOutcome.WIN); assertEquals(b2.getHand().getOutcome(), HandOutcome.LOSS); } @Test void testSameRankDiffPower() { List<Bet> bets = new ArrayList<>(); Bet b1 = new Bet(10); ClassifiedHand c1 = new ClassifiedHand("Foo", 1, 10); b1.getHand().classifyHand(c1); b1.getHand().setLoser(false); Bet b2 = new Bet(10); ClassifiedHand c2 = new ClassifiedHand("Foo", 1, 6); b2.getHand().setLoser(false); b2.getHand().classifyHand(c2); BetEvaluator myBetEvaluator = new BetEvaluator(); myBetEvaluator.evaluateBets(List.of(b1,b2)); assertEquals(HandOutcome.WIN, b1.getHand().getOutcome()); assertEquals( HandOutcome.LOSS, b2.getHand().getOutcome()); } @Test void testSameRankSamePower() { List<Bet> bets = new ArrayList<>(); Bet b1 = new Bet(10); ClassifiedHand c1 = new ClassifiedHand("Foo", 1, 6); b1.getHand().classifyHand(c1); b1.getHand().setLoser(false); Bet b2 = new Bet(10); ClassifiedHand c2 = new ClassifiedHand("Foo", 1, 6); b2.getHand().setLoser(false); b2.getHand().classifyHand(c2); BetEvaluator myBetEvaluator = new BetEvaluator(); myBetEvaluator.evaluateBets(List.of(b1,b2)); assertEquals(HandOutcome.TIE, b1.getHand().getOutcome()); assertEquals(HandOutcome.TIE, b2.getHand().getOutcome()); } @Test void testMultipleHandsOneWinner() { Bet b1 = new Bet(10); Bet b2 = new Bet(10); Bet b3 = new Bet(10); ClassifiedHand c1 = new ClassifiedHand("Foo", 1, 6); ClassifiedHand c2 = new ClassifiedHand("Foo", 2, 6); ClassifiedHand c3 = new ClassifiedHand("Foo", 3, 6); b1.getHand().classifyHand(c1); b2.getHand().classifyHand(c2); b3.getHand().classifyHand(c3); BetEvaluator myBetEvaluator = new BetEvaluator(); myBetEvaluator.evaluateBets(List.of(b1,b2, b3)); assertEquals(HandOutcome.WIN, b1.getHand().getOutcome()); assertEquals(HandOutcome.LOSS, b2.getHand().getOutcome()); assertEquals(HandOutcome.LOSS, b3.getHand().getOutcome()); } @Test void testMultipleHandsMultipleWinners() { Bet b1 = new Bet(10); Bet b2 = new Bet(10); Bet b3 = new Bet(10); ClassifiedHand c1 = new ClassifiedHand("Foo", 1, 6); ClassifiedHand c2 = new ClassifiedHand("Foo", 1, 6); ClassifiedHand c3 = new ClassifiedHand("Foo", 3, 6); b1.getHand().classifyHand(c1); b2.getHand().classifyHand(c2); b3.getHand().classifyHand(c3); BetEvaluator myBetEvaluator = new BetEvaluator(); myBetEvaluator.evaluateBets(List.of(b1,b2, b3)); assertEquals(HandOutcome.TIE, b1.getHand().getOutcome()); assertEquals(HandOutcome.TIE, b2.getHand().getOutcome()); assertEquals(HandOutcome.LOSS, b3.getHand().getOutcome()); } @Test void testMultipleHandsAllWinners() { Bet b1 = new Bet(10); Bet b2 = new Bet(10); Bet b3 = new Bet(10); Bet b4 = new Bet(10); ClassifiedHand c1 = new ClassifiedHand("Foo", 1, 6); b1.getHand().classifyHand(c1); b2.getHand().classifyHand(c1); b3.getHand().classifyHand(c1); b4.getHand().classifyHand(c1); BetEvaluator myBetEvaluator = new BetEvaluator(); myBetEvaluator.evaluateBets(List.of(b1,b2, b3, b4)); assertEquals(HandOutcome.TIE, b1.getHand().getOutcome()); assertEquals(HandOutcome.TIE, b2.getHand().getOutcome()); assertEquals(HandOutcome.TIE, b3.getHand().getOutcome()); assertEquals(HandOutcome.TIE, b4.getHand().getOutcome()); } @Test void testWinnerLoserBug() { PlayerHand playerHand = new PlayerHand(); playerHand.acceptCard(new Card("hearts", 14)); playerHand.classifyHand(new ClassifiedHand("Guy", 1, 1)); PlayerHand adversaryHand = new PlayerHand(); adversaryHand.acceptCard(new Card("hearts", 22)); adversaryHand.classifyHand(new ClassifiedHand("Guy", 2, 1)); BetEvaluator myBetEvaluator = new BetEvaluator(); myBetEvaluator.evaluateHands(playerHand, adversaryHand); assertEquals(HandOutcome.LOSS, adversaryHand.getOutcome()); assertEquals(HandOutcome.WIN, playerHand.getOutcome()); } }
36.575342
68
0.633333
2cf1e38dda13cedd79e5ccbd701ea92dbc0b56ec
3,959
package org.egov.bookings.contract; import java.util.ArrayList; import java.util.List; import java.util.Objects; import javax.validation.Valid; import javax.validation.constraints.NotNull; import org.egov.common.contract.response.ResponseInfo; import org.egov.bookings.model.ActionHistory; import org.egov.bookings.model.Service; import org.springframework.validation.annotation.Validated; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.NoArgsConstructor; /** * Response to the service request */ @Validated @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2018-03-23T08:00:37.661Z") @AllArgsConstructor @NoArgsConstructor @Builder @JsonInclude(JsonInclude.Include.NON_NULL) public class ServiceResponse { @JsonProperty("ResponseInfo") private ResponseInfo responseInfo = null; @JsonProperty("services") @Valid private List<Service> services = new ArrayList<Service>(); @JsonProperty("actionHistory") @Valid private List<ActionHistory> actionHistory = null; public ServiceResponse responseInfo(ResponseInfo responseInfo) { this.responseInfo = responseInfo; return this; } /** * Get responseInfo * @return responseInfo **/ @NotNull @Valid public ResponseInfo getResponseInfo() { return responseInfo; } public void setResponseInfo(ResponseInfo responseInfo) { this.responseInfo = responseInfo; } public ServiceResponse services(List<Service> services) { this.services = services; return this; } public ServiceResponse addServicesItem(Service servicesItem) { this.services.add(servicesItem); return this; } /** * Get services * @return services **/ @NotNull @Valid public List<Service> getServices() { return services; } public void setServices(List<Service> services) { this.services = services; } public ServiceResponse actionHistory(List<ActionHistory> actionHistory) { this.actionHistory = actionHistory; return this; } public ServiceResponse addActionHistoryItem(ActionHistory actionHistoryItem) { if (this.actionHistory == null) { this.actionHistory = new ArrayList<ActionHistory>(); } this.actionHistory.add(actionHistoryItem); return this; } /** * Get actionHistory * @return actionHistory **/ @Valid public List<ActionHistory> getActionHistory() { return actionHistory; } public void setActionHistory(List<ActionHistory> actionHistory) { this.actionHistory = actionHistory; } @Override public boolean equals(java.lang.Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ServiceResponse serviceResponse = (ServiceResponse) o; return Objects.equals(this.responseInfo, serviceResponse.responseInfo) && Objects.equals(this.services, serviceResponse.services) && Objects.equals(this.actionHistory, serviceResponse.actionHistory); } @Override public int hashCode() { return Objects.hash(responseInfo, services, actionHistory); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ServiceResponse {\n"); sb.append(" responseInfo: ").append(toIndentedString(responseInfo)).append("\n"); sb.append(" services: ").append(toIndentedString(services)).append("\n"); sb.append(" actionHistory: ").append(toIndentedString(actionHistory)).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 "); } }
24.438272
116
0.71028
d53042f0ea922bd2590115466c0755640a23bee4
5,629
/******************************************************************************* * Copyright (c) 2017 Pegasystems Inc. All rights reserved. * * Contributors: * Manu Varghese *******************************************************************************/ package com.pega.gcs.tracerviewer.view; import java.awt.Dimension; import java.awt.LayoutManager; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JPanel; import com.pega.gcs.fringecommon.guiutilities.CustomJTable; import com.pega.gcs.fringecommon.guiutilities.treetable.DefaultTreeTableTreeModel; import com.pega.gcs.fringecommon.guiutilities.treetable.TreeTableColumn; import com.pega.gcs.tracerviewer.TraceEventTreeNode; import com.pega.gcs.tracerviewer.TraceNavigationTableController; import com.pega.gcs.tracerviewer.TraceTableModel; import com.pega.gcs.tracerviewer.TraceTableModelColumn; import com.pega.gcs.tracerviewer.TraceTreeTable; import com.pega.gcs.tracerviewer.TraceTreeTableMouseListener; public class TracerDataTreeTableView extends TracerDataSingleView { private static final long serialVersionUID = -2065567512444191531L; private static final String EXPAND_ALL_ACTION = "Expand all nodes"; private static final String COLLAPSE_ALL_ACTION = "Collapse all nodes"; private TraceTreeTable traceTreeTable; private JButton expandAllJButton; public TracerDataTreeTableView(TraceTableModel traceTableModel, JPanel supplementUtilityJPanel, TraceNavigationTableController traceNavigationTableController) { super(traceTableModel, supplementUtilityJPanel, traceNavigationTableController); } @Override protected CustomJTable getTracerDataTable() { if (traceTreeTable == null) { TraceTableModel traceTableModel = getTraceTableModel(); TraceEventTreeNode root = traceTableModel.getRootTraceEventTreeNode(); TraceTableModelColumn[] traceTreeTableModelColumnArray; traceTreeTableModelColumnArray = TraceTableModelColumn.getTraceTreeTableModelColumnArray(); TreeTableColumn[] columns = getTreeTableColumnArray(traceTreeTableModelColumnArray); DefaultTreeTableTreeModel dtttm = new DefaultTreeTableTreeModel(root, columns); traceTreeTable = new TraceTreeTable(dtttm, traceTableModel); TraceTreeTableMouseListener traceTreeTableMouseListener = new TraceTreeTableMouseListener(this); traceTreeTableMouseListener.addTraceTreeTable(traceTreeTable); traceTreeTable.addMouseListener(traceTreeTableMouseListener); } return traceTreeTable; } @Override protected JPanel getAdditionalUtilityPanel() { JPanel additionalUtilityPanel = new JPanel(); LayoutManager layout = new BoxLayout(additionalUtilityPanel, BoxLayout.LINE_AXIS); additionalUtilityPanel.setLayout(layout); JButton expandAllJButton = getExpandAllJButton(); additionalUtilityPanel.add(expandAllJButton); return additionalUtilityPanel; } protected JButton getExpandAllJButton() { if (expandAllJButton == null) { expandAllJButton = new JButton(EXPAND_ALL_ACTION); expandAllJButton.setActionCommand(EXPAND_ALL_ACTION); Dimension dim = new Dimension(150, 20); expandAllJButton.setPreferredSize(dim); expandAllJButton.setMaximumSize(dim); expandAllJButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JButton expandAllJButton = getExpandAllJButton(); TraceTreeTable traceTreeTable = (TraceTreeTable) getTracerDataTable(); if (EXPAND_ALL_ACTION.equals(event.getActionCommand())) { if (traceTreeTable != null) { traceTreeTable.expandAll(true); } expandAllJButton.setText(COLLAPSE_ALL_ACTION); expandAllJButton.setActionCommand(COLLAPSE_ALL_ACTION); } else { if (traceTreeTable != null) { traceTreeTable.expandAll(false); } expandAllJButton.setText(EXPAND_ALL_ACTION); expandAllJButton.setActionCommand(EXPAND_ALL_ACTION); } } }); } return expandAllJButton; } protected TreeTableColumn[] getTreeTableColumnArray(TraceTableModelColumn[] traceTableModelColumnArray) { TreeTableColumn[] columns = null; int columnIndex = 0; String columnName; int prefColumnWidth; int alignment; Class<?> columnClass; int size = traceTableModelColumnArray.length; columns = new TreeTableColumn[size]; for (TraceTableModelColumn traceTableModelColumn : traceTableModelColumnArray) { columnName = traceTableModelColumn.getName(); prefColumnWidth = traceTableModelColumn.getPrefColumnWidth(); alignment = traceTableModelColumn.getHorizontalAlignment(); columnClass = traceTableModelColumn.getColumnClass(); TreeTableColumn column = new TreeTableColumn(columnName, prefColumnWidth, alignment, columnClass); columns[columnIndex] = column; columnIndex++; } return columns; } }
34.115152
110
0.669924
779f6dc109ec85bd2528cfa0917194568d8fdb44
1,368
package org.foraci.mxf.mxfTool.gui; import org.foraci.mxf.mxfReader.PartitionPack; import org.foraci.mxf.mxfReader.RandomIndexPack; import org.foraci.mxf.mxfReader.entities.GroupNode; import org.foraci.mxf.mxfTool.dataMgrs.AnalyzeEssenceContainerController; import org.foraci.mxf.mxfTool.dataMgrs.EssenceTrack; import javax.swing.tree.DefaultMutableTreeNode; import java.io.File; import java.util.List; import java.util.Set; /** * Represents the interface into the UI for an MXF asset */ public interface MxfView { GroupNode getRootGroupNode(); Set<GroupNode> getGroups(); List<PartitionPack> getPartitionPackList(); RandomIndexPack getRandomIndexPack(); void setRandomIndexPack(RandomIndexPack randomIndexPack); File getFile(); List<File> getExternalFileList(); List<EssenceTrack> getExportableTrackList(); CaptionServicePanel getCaptionServicePanel(int serviceNumber); AncillaryDataPanel getAncPacketListener(); DolbyETrackInfoPanel getDolbyEInfoPanel(EssenceTrack track); DefaultMutableTreeNode getStructureTreeRoot(); AnalyzeEssenceContainerController getEssenceController(); boolean isDebug(); void debug(String message); void info(String message); void warn(String message); void error(String message, Exception e); void dump(String line); }
35.076923
74
0.761696
030231a7da5e70ac7b315287c1166614652dfc52
3,053
begin_unit|revision:0.9.5;language:Java;cregit-version:0.0.1 begin_comment comment|/* * 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. */ end_comment begin_package DECL|package|org.apache.camel.util.function package|package name|org operator|. name|apache operator|. name|camel operator|. name|util operator|. name|function package|; end_package begin_import import|import name|java operator|. name|util operator|. name|Objects import|; end_import begin_import import|import name|java operator|. name|util operator|. name|function operator|. name|Predicate import|; end_import begin_comment comment|/** * Predicate helpers, inspired by http://minborgsjavapot.blogspot.it/2016/03/put-your-java-8-method-references-to.html * */ end_comment begin_class DECL|class|Predicates specifier|public specifier|final class|class name|Predicates block|{ DECL|method|Predicates () specifier|private name|Predicates parameter_list|() block|{ } comment|/** * Wrap a predicate, useful for method references. */ DECL|method|of (Predicate<T> predicate) specifier|public specifier|static parameter_list|< name|T parameter_list|> name|Predicate argument_list|< name|T argument_list|> name|of parameter_list|( name|Predicate argument_list|< name|T argument_list|> name|predicate parameter_list|) block|{ name|Objects operator|. name|requireNonNull argument_list|( name|predicate argument_list|, literal|"Predicate must be specified" argument_list|) expr_stmt|; return|return name|predicate return|; block|} comment|/** * Negates a predicate, useful for method references. * *<pre> * Stream.of("A", "", "B") * .filter(Predicates.negate(String::isEmpty)) * .count(); *</pre> */ DECL|method|negate (Predicate<T> predicate) specifier|public specifier|static parameter_list|< name|T parameter_list|> name|Predicate argument_list|< name|T argument_list|> name|negate parameter_list|( name|Predicate argument_list|< name|T argument_list|> name|predicate parameter_list|) block|{ name|Objects operator|. name|requireNonNull argument_list|( name|predicate argument_list|, literal|"Predicate must be specified" argument_list|) expr_stmt|; return|return name|predicate operator|. name|negate argument_list|() return|; block|} block|} end_class end_unit
22.954887
810
0.762529
347670ee912e96823fdf26c0d0596d4ee2e16629
3,127
package com.figaf.integration.cpi.client; import com.figaf.integration.common.client.RestTemplateWrapperHolder; import com.figaf.integration.common.entity.ConnectionProperties; import com.figaf.integration.common.factory.HttpClientsFactory; import com.figaf.integration.common.factory.RestTemplateWrapperFactory; import com.figaf.integration.cpi.entity.message_sender.MessageSendingAdditionalProperties; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; /** * @author Klochkov Sergey */ @Slf4j public abstract class MessageSender { protected final HttpClientsFactory httpClientsFactory; protected final RestTemplateWrapperHolder restTemplateWrapperHolder; protected MessageSender(HttpClientsFactory httpClientsFactory) { this.httpClientsFactory = httpClientsFactory; this.restTemplateWrapperHolder = new RestTemplateWrapperHolder(new RestTemplateWrapperFactory(httpClientsFactory)); } public ResponseEntity<String> sendMessage( ConnectionProperties connectionProperties, String url, HttpMethod httpMethod, HttpEntity<byte[]> requestEntity, MessageSendingAdditionalProperties messageSendingAdditionalProperties ) { log.debug("#sendMessage(ConnectionProperties testSystemProperties, String url, HttpMethod httpMethod, " + "HttpEntity<byte[]> requestEntity, MessageSendingAdditionalProperties messageSendingAdditionalProperties): " + "{}, {}, {}, {}, {}", connectionProperties, url, httpMethod, requestEntity, messageSendingAdditionalProperties); switch (messageSendingAdditionalProperties.getAuthenticationType()) { case BASIC: return sendMessageWithBasicAuthentication( connectionProperties, url, httpMethod, requestEntity, messageSendingAdditionalProperties ); case OAUTH: return sendMessageWithOAuth( connectionProperties, url, httpMethod, requestEntity, messageSendingAdditionalProperties ); default: throw new IllegalArgumentException("Unexpected authentication type " + messageSendingAdditionalProperties.getAuthenticationType()); } } protected abstract ResponseEntity<String> sendMessageWithBasicAuthentication( ConnectionProperties connectionProperties, String url, HttpMethod httpMethod, HttpEntity<byte[]> requestEntity, MessageSendingAdditionalProperties messageSendingAdditionalProperties ); protected abstract ResponseEntity<String> sendMessageWithOAuth( ConnectionProperties connectionProperties, String url, HttpMethod httpMethod, HttpEntity<byte[]> requestEntity, MessageSendingAdditionalProperties messageSendingAdditionalProperties ); }
41.144737
147
0.710585
e575fe7f55063cdfc8ecb4caa07bf6d353355c89
1,562
package no.ion.jake.graph; import java.util.EnumSet; import java.util.Map; import java.util.Objects; public class BuildNode<ID extends NodeId> { private static final Map<State, EnumSet<State>> LEGAL_STATE_TRANSITIONS = Map.of( State.PENDING, EnumSet.of(State.ACTIVE)); private final BuildMeta<ID> buildMeta; private float minTimeSeconds = -1; private State state = State.PENDING; public BuildNode(BuildMeta<ID> buildMeta) { this.buildMeta = buildMeta; } public BuildMeta<ID> buildMeta() { return buildMeta; } public float minTimeSeconds() { return minTimeSeconds; } public enum State {PENDING, ACTIVE} public State state() { return state; } public void setState(State newState) { Objects.requireNonNull(newState); if (!LEGAL_STATE_TRANSITIONS.get(state).contains(newState)) { throw new IllegalStateException("illegal state transition: " + state + " -> " + newState); } state = newState; } public float updateMinTimeSeconds(float minTimeOfDependencies) { // Use 0.001f to enforce strictly increasing minTimeSeconds in the critical path chain. minTimeSeconds = Math.max(0.001f, minTimeOfDependencies) + buildMeta.expectedBuildDuration().toMillis() / 1000f; return minTimeSeconds; } @Override public String toString() { return "BuildNode{" + "buildMeta=" + buildMeta + ", minTimeSeconds=" + minTimeSeconds + ", state=" + state + '}'; } }
32.541667
120
0.654289
d80c43b7fcd0597c646309e0872e18cdaa02191e
2,046
package com.hubspot.singularity.data; import static com.google.common.base.Preconditions.checkState; import javax.inject.Singleton; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.recipes.atomic.AtomicValue; import org.apache.curator.framework.recipes.atomic.DistributedAtomicInteger; import org.apache.curator.retry.RetryOneTime; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import com.google.inject.Inject; @Singleton public class ExecutorIdGenerator { private volatile DistributedAtomicInteger distributedGenerator = null; private final char[] alphabet; private static final String COUNTER_PATH = "/executors/counter"; private final CuratorFramework curator; @Inject public ExecutorIdGenerator(CuratorFramework curator) { this.curator = curator; this.alphabet = buildAlphabet(); } public void start() { this.distributedGenerator = new DistributedAtomicInteger(curator, COUNTER_PATH, new RetryOneTime(1)); } public String getNextExecutorId() { checkState(distributedGenerator != null, "never started!"); try { AtomicValue<Integer> atomic = distributedGenerator.increment(); Preconditions.checkState(atomic.succeeded(), "Atomic increment did not succeed"); return convertUsingAlphabet(atomic.postValue()); } catch (Throwable t) { throw Throwables.propagate(t); } } private String convertUsingAlphabet(int number) { final StringBuilder bldr = new StringBuilder(); while (number > 0) { int remainder = number % alphabet.length; bldr.append(alphabet[remainder]); number = number / alphabet.length; } return bldr.toString(); } private char[] buildAlphabet() { final char[] alphabet = new char[36]; int c = 0; // add integers for (int i = 48; i < 58; i++) { alphabet[c++] = (char) i; } // add letters for (int i = 97; i < 123; i++) { alphabet[c++] = (char) i; } return alphabet; } }
26.571429
105
0.7087
c409b125551eb883357d44df4501b12d8c394926
815
package com.lovecyy.oauth2.service.config.validate; import lombok.Data; import java.awt.image.BufferedImage; import java.time.LocalDateTime; /** * @author ys * @topic 验证码信息类 * @date 2019/9/18 14:59 */ @Data public class ValidateCode { /** * 随机数 */ private String code; /** * 过期时间 */ private LocalDateTime expireTime; public ValidateCode(String code, LocalDateTime expireTime) { this.code = code; this.expireTime = expireTime; } public ValidateCode(String code, int expireIn) { this.code = code; //当前时间 加上 设置过期的时间 this.expireTime = LocalDateTime.now().plusSeconds(expireIn); } public boolean isExpried(){ //如果 过期时间 在 当前日期 之前,则验证码过期 return LocalDateTime.now().isAfter(expireTime); } }
18.953488
68
0.629448
909e61d49577768d0be38b55647dd3c4e28ed6ff
1,554
package com.giffing.bucket4j.spring.boot.starter.config.metrics.actuator; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricHandler; import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricTagResult; import com.giffing.bucket4j.spring.boot.starter.context.metrics.MetricType; import io.micrometer.core.instrument.Metrics; @Component @Primary public class Bucket4jMetricHandler implements MetricHandler { @Override public void handle(MetricType type, String name, long tokens, List<MetricTagResult> tags) { List<String> extendedTags = new ArrayList<>(); extendedTags.add("name"); extendedTags.add(name); tags .stream() .filter(tag -> tag.getTypes().contains(type)) .forEach(metricTagResult -> { extendedTags.add(metricTagResult.getKey()); extendedTags.add(metricTagResult.getValue()); }); String[] extendedTagsArray = extendedTags.toArray(new String[0]); switch(type) { case CONSUMED_COUNTER: Metrics .counter("bucket4j_summary_consumed", extendedTagsArray) .increment(tokens); break; case REJECTED_COUNTER: Metrics .counter("bucket4j_summary_rejected", extendedTagsArray) .increment(tokens); break; default: throw new IllegalStateException("Unsupported metric type: " + type); } } }
28.254545
93
0.736165
52472f4637509134b7ccf7895e89f9ff4e58d088
2,020
// Copyright 2007 The Apache Software Foundation // // 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.apache.tapestry5.integration.app1.pages; import org.apache.tapestry5.annotations.Component; import org.apache.tapestry5.corelib.components.Form; import org.apache.tapestry5.integration.app1.data.ToDoItem; import org.apache.tapestry5.integration.app1.services.ToDoDatabase; import org.apache.tapestry5.ioc.annotations.Inject; import java.util.List; public class ToDoListVolatile { @Inject private ToDoDatabase database; private ToDoItem item; private List<ToDoItem> items; @Component private Form form; public List<ToDoItem> getItems() { return items; } public ToDoItem getItem() { return item; } public void setItem(ToDoItem item) { this.item = item; } public ToDoDatabase getDatabase() { return database; } void onPrepare() { items = database.findAll(); } void onSuccess() { int order = 0; for (ToDoItem item : items) { item.setOrder(order++); database.update(item); } } void onSelectedFromAddNew() { if (form.isValid()) { ToDoItem item = new ToDoItem(); item.setTitle("<New To Do>"); item.setOrder(items.size()); database.add(item); } } void onActionFromReset() { database.reset(); } }
22.444444
75
0.643564
c72628bb9758f17bb36cdcfa29a7381740116213
6,590
/** * This software is released as part of the Pumpernickel project. * All com.pump resources in the Pumpernickel project are distributed under the * MIT License: * https://raw.githubusercontent.com/mickleness/pumpernickel/master/License.txt * More information about the Pumpernickel project is available here: * https://mickleness.github.io/pumpernickel/ */ package com.pump.swing; import com.pump.graphics.vector.FilteredGraphics2D; import com.pump.graphics.vector.StringOperation; import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.plaf.TextUI; import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeListener; import java.lang.reflect.Constructor; /** * This is an untouchable text field that sits on top of a parent * <code>JTextField</code> providing a text prompt. */ public class TextFieldPrompt extends JTextField { private static final long serialVersionUID = 1L; final PropertyChangeListener propertyListener = evt -> { String n = evt.getPropertyName(); if (n.equals("useSearchIcon") || n.equals("JTextField.variant")) { putClientProperty(n, evt.getNewValue()); } }; final ComponentAdapter componentListener = new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { updateBounds(); } }; private int adjustingBounds = 0; final HierarchyListener hierarchyListener = e -> updateVisibility(); /** * Creates a new <code>TextFieldPrompt</code>. * * @param parent * the text field to add this prompt to. * @param promptText * the text to display as the prompt. This can easily be * controlled with <code>getText()</code> and * <code>setText()</code>. */ public TextFieldPrompt(JTextField parent, String promptText) { this(parent, null, promptText); } final FocusListener focusListener = new FocusListener() { public void focusGained(FocusEvent e) { updateVisibility(); } public void focusLost(FocusEvent e) { updateVisibility(); } }; /** * Creates a new <code>TextFieldPrompt</code>. * * @param parent * the text field to add this prompt to. * @param promptColor * the color of this prompt text. * @param promptText * the text to display as the prompt. This can easily be * controlled with <code>getText()</code> and * <code>setText()</code>. */ public TextFieldPrompt(JTextField parent, Color promptColor, String promptText) { super(promptText); if (promptColor == null) {promptColor = Color.gray;} parent.add(this); setFocusable(false); setEditable(false); setForeground(promptColor); setOpaque(false); addHierarchyListener(hierarchyListener); parent.addComponentListener(componentListener); addComponentListener(componentListener); parent.addFocusListener(focusListener); parent.getDocument().addDocumentListener(documentListener); parent.addPropertyChangeListener(propertyListener); putClientProperty("useSearchIcon", parent.getClientProperty("useSearchIcon")); putClientProperty("JTextField.variant", parent.getClientProperty("JTextField.variant")); updateBounds(); try { try { TextUI ui = parent.getUI(); Constructor<?> noArgConstructor = ui.getClass() .getConstructor(); TextUI newUI = (TextUI) noArgConstructor .newInstance(new Object[]{}); setUI(newUI); return; } catch (Throwable ignored) { } try { TextUI ui = parent.getUI(); Constructor<?> noArgConstructor = ui.getClass() .getConstructor(JTextField.class); TextUI newUI = (TextUI) noArgConstructor .newInstance(new Object[]{this}); setUI(newUI); } catch (RuntimeException e) { throw e; } catch (Throwable t) { RuntimeException e2 = new RuntimeException(t); throw e2; } } finally { updateVisibility(); } } final DocumentListener documentListener = new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { } @Override public void insertUpdate(DocumentEvent e) { updateVisibility(); } @Override public void removeUpdate(DocumentEvent e) { insertUpdate(e); } }; @SuppressWarnings("unchecked") @Override public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; super.paint(new FilteredGraphics2D(g2, StringOperation.class)); } @Override public boolean contains(int x, int y) { return false; } private void updateBounds() { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(updateBoundsRunnable); return; } if (adjustingBounds > 0) {return;} adjustingBounds++; try { JTextField parent = (JTextField) getParent(); if (parent != null) {setBounds(0, 0, parent.getWidth(), parent.getHeight());} updateVisibility(); } finally { adjustingBounds--; } } private void updateVisibility() { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(updateVisibilityRunnable); return; } JTextField parent = (JTextField) getParent(); boolean focused = parent != null && parent.hasFocus(); boolean empty = parent == null || parent.getText().length() == 0; setVisible((!focused) && empty); if (isVisible()) {updateBounds();} } private final Runnable updateBoundsRunnable = () -> updateBounds(); private final Runnable updateVisibilityRunnable = () -> updateVisibility(); }
30.368664
124
0.583612
cde324f894923bd0ff2fe823b0bb01cbce7cf7dc
3,566
package com.grainoil.system.controller.application_supporting_platform; import com.grainoil.common.core.controller.BaseController; import com.grainoil.common.core.domain.R; import com.grainoil.system.domain.TbOrganize; import com.grainoil.system.service.ITbOrganizeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; /** * 组织信息管理 */ @RestController @RequestMapping("organize") @Api(tags = "组织管理") public class TbOrganizeController extends BaseController { @Autowired ITbOrganizeService tbOrganizeService; /** * 根据条件分页查询组织信息列表 * * @param organizeName 组织名称 * @param organizeType 组织类型 * @param organizeId 组织id * @return 组织信息集合 */ @ApiOperation(value = "获取组织列表", notes = "根据条件分页查询组织列表信息") @ApiImplicitParams({@ApiImplicitParam(name = "organizeName", value = "组织名称"), @ApiImplicitParam(name = "organizeType", value = "组织类型"), @ApiImplicitParam(name = "organizeId", value = "组织id", required = true)}) @GetMapping("list") public R list(String organizeName, String organizeType, Long organizeId) { startPage(); return result(tbOrganizeService.list(organizeName, organizeType, organizeId)); } /** * 添加组织信息 * * @param organize 组织信息 * @return ok/error */ @ApiOperation(value = "添加组织信息", notes = "添加组织信息") @PostMapping("insert") public R insert(@ApiIgnore TbOrganize organize, Long organizeId) { organize.setCreateId(getCurrentUserId()); organize.setUpdateId(getCurrentUserId()); organize.setCreateBy(getLoginName()); organize.setUpdateBy(getLoginName()); return tbOrganizeService.insert(organize, organizeId); } /** * 获取组织管理树 * * @param organizeId 树的根节点id * @return 组织管理树结构 */ @ApiOperation(value = "获取组织管理树", notes = "获取组织管理树") @ApiImplicitParams({@ApiImplicitParam(name = "organizeId", value = "当前用户所属的组织id", required = true)}) @GetMapping("getTree") public R getTree(Long organizeId) { return R.data(tbOrganizeService.getTree(organizeId)); } /** * 根据id获取组织信息 * * @param organizeId 组织id * @return 组织信息 */ @GetMapping("get/{organizeId}") @ApiOperation(value = "根据id获取组织信息", notes = "根据id获取组织信息") @ApiImplicitParams({@ApiImplicitParam(name = "organizeId", value = "组织id", required = true)}) public R get(@PathVariable("organizeId") Long organizeId) { return tbOrganizeService.get(organizeId); } /** * 修改组织信息 * * @param organize 组织信息 * @return ok/error */ @PostMapping("update") @ApiOperation(value = "修改组织信息", notes = "修改组织信息") public R update(TbOrganize organize) { organize.setUpdateBy(getLoginName()); organize.setUpdateId(getCurrentUserId()); return tbOrganizeService.update(organize); } /** * 获取所有的企业的下拉框 * * @return 所有的企业的下拉框 */ @ApiOperation("获取所有的企业的下拉框") @GetMapping("getSelect") public R getSelect() { return tbOrganizeService.getSelect(); } /** * 获取区粮管中心组织的下拉框 * * @return 所有的企业的下拉框 */ @ApiOperation("获取区粮管中心组织的下拉框") @GetMapping("getCenter") public R getCenter() { return tbOrganizeService.getCenter(); } }
29.716667
213
0.669097
613ef4de4ab4993781f813d424ae8001e5b19280
719
package agency.tango.viking.example.dialog.mvp; import agency.tango.viking.annotations.AutoModule; import agency.tango.viking.example.R; import agency.tango.viking.mvp.DialogFragmentScreen; import androidx.fragment.app.DialogFragment; @AutoModule public class VikingDialogFragment extends DialogFragmentScreen<VikingDialogContract.View, VikingDialogPresenter> implements VikingDialogContract.View { public static VikingDialogFragment newInstance() { VikingDialogFragment fragment = new VikingDialogFragment(); fragment.setStyle(DialogFragment.STYLE_NO_TITLE, 0); return fragment; } public VikingDialogFragment() { super(R.layout.fragment_viking_dialog, VikingDialogPresenter.class); } }
32.681818
112
0.815021
4947e467ff63d32950ab02fc92aaadec96a37bef
1,139
/* * acme4j - Java ACME client * * Copyright (C) 2016 Richard "Shred" Körber * http://acme4j.shredzone.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * * 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. */ package org.shredzone.acme4j.exception; import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.concurrent.Immutable; import java.io.IOException; /** * This exception is thrown when a network error occurred while communicating with the * server. */ @ParametersAreNonnullByDefault @Immutable public class AcmeNetworkException extends AcmeException { private static final long serialVersionUID = 2054398693543329179L; /** * Create a new {@link AcmeNetworkException}. * * @param cause {@link IOException} that caused the network error */ public AcmeNetworkException(IOException cause) { super("Network error", cause); } }
29.973684
86
0.738367