You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by bh...@apache.org on 2019/04/11 12:38:40 UTC

[incubator-dlab] 02/02: DLAB-000 removed not needed classes

This is an automated email from the ASF dual-hosted git repository.

bhliva pushed a commit to branch refactoring
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit 54514731ac6953d669d343eed9ee6a8689091140
Author: bhliva <bo...@epam.com>
AuthorDate: Thu Apr 11 15:38:19 2019 +0300

    DLAB-000 removed not needed classes
---
 .../ComputationalResourceShapeDto.java             | 208 ++++++++++-----------
 .../java/com/epam/dlab/util/AnnotationUtils.java   |  61 ------
 .../main/java/com/epam/dlab/util/ObjectUtils.java  |  49 -----
 3 files changed, 98 insertions(+), 220 deletions(-)

diff --git a/services/dlab-model/src/main/java/com/epam/dlab/dto/imagemetadata/ComputationalResourceShapeDto.java b/services/dlab-model/src/main/java/com/epam/dlab/dto/imagemetadata/ComputationalResourceShapeDto.java
index 4364e63..30e7880 100644
--- a/services/dlab-model/src/main/java/com/epam/dlab/dto/imagemetadata/ComputationalResourceShapeDto.java
+++ b/services/dlab-model/src/main/java/com/epam/dlab/dto/imagemetadata/ComputationalResourceShapeDto.java
@@ -19,118 +19,106 @@
 
 package com.epam.dlab.dto.imagemetadata;
 
-import com.epam.dlab.util.ObjectUtils;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 
-import java.util.Objects;
-
 public class ComputationalResourceShapeDto {
-    @JsonProperty("Type")
-    private String type;
-    @JsonProperty("Size")
-    private String size;
-    @JsonProperty("Description")
-    private String description;
-    @JsonProperty("Ram")
-    private String ram;
-    @JsonProperty("Cpu")
-    private int cpu;
-    @JsonProperty("Spot")
-    private boolean spot = false;
-
-    @JsonProperty("SpotPctPrice")
-    private int spotPctPrice = 70;
-
-
-    public ComputationalResourceShapeDto(){
-    }
-
-    public ComputationalResourceShapeDto(String type, String size, String description, String ram, int cpu) {
-        this.type = type;
-        this.size = size;
-        this.description = description;
-        this.ram = ram;
-        this.cpu = cpu;
-    }
-
-    public ComputationalResourceShapeDto(String type, String size, String description, String ram, int cpu, boolean spot, int spotPctPrice) {
-        this.type = type;
-        this.size = size;
-        this.description = description;
-        this.ram = ram;
-        this.cpu = cpu;
-        this.spot = spot;
-        this.spotPctPrice = spotPctPrice;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public String getSize() { return size; }
-
-    public void setSize(String size) { this.size = size; }
-
-    public String getDescription() { return description; }
-
-    public void setDescription(String description) { this.description = description; }
-
-    public String getRam() {
-        return ram;
-    }
-
-    public void setRam(String ram) {
-        this.ram = ram;
-    }
-
-    public int getCpu() {
-        return cpu;
-    }
-
-    public void setCpu(int cpu) {
-        this.cpu = cpu;
-    }
-
-    public boolean isSpot() {
-        return spot;
-    }
-
-    public void setSpot(boolean spot) {
-        this.spot = spot;
-    }
-
-    public int getSpotPctPrice() {
-        return spotPctPrice;
-    }
-
-    public void setSpotPctPrice(int spotPctPrice) {
-        this.spotPctPrice = spotPctPrice;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        return ObjectUtils.areObjectsEqual(this, obj,
-                o -> o.type,
-                o -> o.size,
-                o -> o.description,
-                o -> o.ram,
-                o -> o.cpu,
-                o -> o.spot,
-                o -> o.spotPctPrice);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(type, size, description, ram, cpu, spot, spotPctPrice);
-    }
-
-    @Override
-    public String toString() {
-        return ReflectionToStringBuilder.toString(this);
-    }
+	@JsonProperty("Type")
+	private String type;
+	@JsonProperty("Size")
+	private String size;
+	@JsonProperty("Description")
+	private String description;
+	@JsonProperty("Ram")
+	private String ram;
+	@JsonProperty("Cpu")
+	private int cpu;
+	@JsonProperty("Spot")
+	private boolean spot = false;
+
+	@JsonProperty("SpotPctPrice")
+	private int spotPctPrice = 70;
+
+
+	public ComputationalResourceShapeDto() {
+	}
+
+	public ComputationalResourceShapeDto(String type, String size, String description, String ram, int cpu) {
+		this.type = type;
+		this.size = size;
+		this.description = description;
+		this.ram = ram;
+		this.cpu = cpu;
+	}
+
+	public ComputationalResourceShapeDto(String type, String size, String description, String ram, int cpu, boolean spot, int spotPctPrice) {
+		this.type = type;
+		this.size = size;
+		this.description = description;
+		this.ram = ram;
+		this.cpu = cpu;
+		this.spot = spot;
+		this.spotPctPrice = spotPctPrice;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getSize() {
+		return size;
+	}
+
+	public void setSize(String size) {
+		this.size = size;
+	}
+
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+	public String getRam() {
+		return ram;
+	}
+
+	public void setRam(String ram) {
+		this.ram = ram;
+	}
+
+	public int getCpu() {
+		return cpu;
+	}
+
+	public void setCpu(int cpu) {
+		this.cpu = cpu;
+	}
+
+	public boolean isSpot() {
+		return spot;
+	}
+
+	public void setSpot(boolean spot) {
+		this.spot = spot;
+	}
+
+	public int getSpotPctPrice() {
+		return spotPctPrice;
+	}
+
+	public void setSpotPctPrice(int spotPctPrice) {
+		this.spotPctPrice = spotPctPrice;
+	}
+
+	@Override
+	public String toString() {
+		return ReflectionToStringBuilder.toString(this);
+	}
 }
diff --git a/services/dlab-utils/src/main/java/com/epam/dlab/util/AnnotationUtils.java b/services/dlab-utils/src/main/java/com/epam/dlab/util/AnnotationUtils.java
deleted file mode 100644
index 64c75b3..0000000
--- a/services/dlab-utils/src/main/java/com/epam/dlab/util/AnnotationUtils.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.epam.dlab.util;
-
-import lombok.extern.slf4j.Slf4j;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Map;
-
-@Slf4j
-public class AnnotationUtils {
-
-	private static final String ANNOTATION_METHOD = "annotationData";
-	private static final String ANNOTATIONS = "annotations";
-
-	private AnnotationUtils() {
-	}
-
-	public static void updateAnnotation(Class<?> targetClass, Class<? extends Annotation> targetAnnotation,
-										Annotation targetValue) {
-		alterAnnotationValue(targetClass, targetAnnotation, targetValue);
-	}
-
-	@SuppressWarnings("unchecked")
-	private static void alterAnnotationValue(Class<?> targetClass, Class<? extends Annotation> targetAnnotation,
-											 Annotation targetValue) {
-		try {
-			Method method = Class.class.getDeclaredMethod(ANNOTATION_METHOD);
-			method.setAccessible(true);
-
-			Object annotationData = method.invoke(targetClass);
-
-			Field annotations = annotationData.getClass().getDeclaredField(ANNOTATIONS);
-			annotations.setAccessible(true);
-
-			Map<Class<? extends Annotation>, Annotation> map = (Map<Class<? extends Annotation>, Annotation>)
-					annotations.get(annotationData);
-			map.put(targetAnnotation, targetValue);
-		} catch (Exception e) {
-			log.error("An exception occured: {}", e.getLocalizedMessage());
-		}
-	}
-}
diff --git a/services/dlab-utils/src/main/java/com/epam/dlab/util/ObjectUtils.java b/services/dlab-utils/src/main/java/com/epam/dlab/util/ObjectUtils.java
deleted file mode 100644
index 94a2e32..0000000
--- a/services/dlab-utils/src/main/java/com/epam/dlab/util/ObjectUtils.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.epam.dlab.util;
-
-import java.util.Objects;
-import java.util.function.Function;
-
-public final class ObjectUtils {
-    private ObjectUtils() { }
-
-    @SafeVarargs
-    public static<T> boolean areObjectsEqual(T thiz, Object that,
-                                             Function<T, Object>... getters) {
-        if(thiz == that) {
-            return true;
-        }
-
-        if (that == null || thiz.getClass() != that.getClass()) {
-            return false;
-        }
-
-        @SuppressWarnings("unchecked")
-        T typedThat = (T)that;
-
-        for(Function<T, Object> getter: getters) {
-            if(!Objects.equals(getter.apply(thiz), getter.apply(typedThat))) {
-                return false;
-            }
-        }
-        return true;
-    }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org