Resolves checkstyle errors for abstract-document abstract-factory acyclic-visitor adapter aggregator-microservices (#1080)
* Reduces checkstyle errors in abstract-document * Reduces checkstyle errors in abstract-factory * Reduces checkstyle errors in acyclic-visitor * Reduces checkstyle errors in adapter * Reduces checkstyle errors in aggregator-microservices
This commit is contained in:
committed by
Ilkka Seppälä
parent
390795154f
commit
1e76d91929
@ -31,7 +31,7 @@ import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Abstract implementation of Document interface
|
||||
* Abstract implementation of Document interface.
|
||||
*/
|
||||
public abstract class AbstractDocument implements Document {
|
||||
|
||||
@ -64,7 +64,8 @@ public abstract class AbstractDocument implements Document {
|
||||
public String toString() {
|
||||
var builder = new StringBuilder();
|
||||
builder.append(getClass().getName()).append("[");
|
||||
properties.forEach((key, value) -> builder.append("[").append(key).append(" : ").append(value).append("]"));
|
||||
properties.forEach((key, value) -> builder.append("[").append(key).append(" : ").append(value)
|
||||
.append("]"));
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
@ -25,46 +25,43 @@ package com.iluwatar.abstractdocument;
|
||||
|
||||
import com.iluwatar.abstractdocument.domain.Car;
|
||||
import com.iluwatar.abstractdocument.domain.enums.Property;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The Abstract Document pattern enables handling additional, non-static
|
||||
* properties. This pattern uses concept of traits to enable type safety and
|
||||
* separate properties of different classes into set of interfaces.
|
||||
* <p>
|
||||
* <p>
|
||||
* In Abstract Document pattern,({@link AbstractDocument}) fully implements
|
||||
* {@link Document}) interface. Traits are then defined to enable access to
|
||||
* properties in usual, static way.
|
||||
* The Abstract Document pattern enables handling additional, non-static properties. This pattern
|
||||
* uses concept of traits to enable type safety and separate properties of different classes into
|
||||
* set of interfaces.
|
||||
*
|
||||
* <p>In Abstract Document pattern,({@link AbstractDocument}) fully implements {@link Document})
|
||||
* interface. Traits are then defined to enable access to properties in usual, static way.
|
||||
*/
|
||||
public class App {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||
|
||||
/**
|
||||
* Executes the App
|
||||
* Executes the App.
|
||||
*/
|
||||
public App() {
|
||||
LOGGER.info("Constructing parts and car");
|
||||
|
||||
var wheelProperties = Map.of(
|
||||
Property.TYPE.toString(), "wheel",
|
||||
Property.MODEL.toString(), "15C",
|
||||
Property.PRICE.toString(), 100L);
|
||||
Property.TYPE.toString(), "wheel",
|
||||
Property.MODEL.toString(), "15C",
|
||||
Property.PRICE.toString(), 100L);
|
||||
|
||||
var doorProperties = Map.of(
|
||||
Property.TYPE.toString(), "door",
|
||||
Property.MODEL.toString(), "Lambo",
|
||||
Property.PRICE.toString(), 300L);
|
||||
Property.TYPE.toString(), "door",
|
||||
Property.MODEL.toString(), "Lambo",
|
||||
Property.PRICE.toString(), 300L);
|
||||
|
||||
var carProperties = Map.of(
|
||||
Property.MODEL.toString(), "300SL",
|
||||
Property.PRICE.toString(), 10000L,
|
||||
Property.PARTS.toString(), List.of(wheelProperties, doorProperties));
|
||||
Property.MODEL.toString(), "300SL",
|
||||
Property.PRICE.toString(), 10000L,
|
||||
Property.PARTS.toString(), List.of(wheelProperties, doorProperties));
|
||||
|
||||
var car = new Car(carProperties);
|
||||
|
||||
@ -72,11 +69,12 @@ public class App {
|
||||
LOGGER.info("-> model: {}", car.getModel().get());
|
||||
LOGGER.info("-> price: {}", car.getPrice().get());
|
||||
LOGGER.info("-> parts: ");
|
||||
car.getParts().forEach(p -> LOGGER.info("\t{}/{}/{}", p.getType().get(), p.getModel().get(), p.getPrice().get()));
|
||||
car.getParts().forEach(p -> LOGGER
|
||||
.info("\t{}/{}/{}", p.getType().get(), p.getModel().get(), p.getPrice().get()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
* Program entry point.
|
||||
*
|
||||
* @param args command line args
|
||||
*/
|
||||
|
@ -28,12 +28,12 @@ import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Document interface
|
||||
* Document interface.
|
||||
*/
|
||||
public interface Document {
|
||||
|
||||
/**
|
||||
* Puts the value related to the key
|
||||
* Puts the value related to the key.
|
||||
*
|
||||
* @param key element key
|
||||
* @param value element value
|
||||
@ -42,7 +42,7 @@ public interface Document {
|
||||
Void put(String key, Object value);
|
||||
|
||||
/**
|
||||
* Gets the value for the key
|
||||
* Gets the value for the key.
|
||||
*
|
||||
* @param key element key
|
||||
* @return value or null
|
||||
@ -50,7 +50,7 @@ public interface Document {
|
||||
Object get(String key);
|
||||
|
||||
/**
|
||||
* Gets the stream of child documents
|
||||
* Gets the stream of child documents.
|
||||
*
|
||||
* @param key element key
|
||||
* @param constructor constructor of child class
|
||||
|
@ -23,12 +23,11 @@
|
||||
|
||||
package com.iluwatar.abstractdocument.domain;
|
||||
|
||||
import com.iluwatar.abstractdocument.AbstractDocument;
|
||||
import java.util.Map;
|
||||
|
||||
import com.iluwatar.abstractdocument.AbstractDocument;
|
||||
|
||||
/**
|
||||
* Car entity
|
||||
* Car entity.
|
||||
*/
|
||||
public class Car extends AbstractDocument implements HasModel, HasPrice, HasParts {
|
||||
|
||||
|
@ -23,13 +23,12 @@
|
||||
|
||||
package com.iluwatar.abstractdocument.domain;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.iluwatar.abstractdocument.Document;
|
||||
import com.iluwatar.abstractdocument.domain.enums.Property;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* HasModel trait for static access to 'model' property
|
||||
* HasModel trait for static access to 'model' property.
|
||||
*/
|
||||
public interface HasModel extends Document {
|
||||
|
||||
|
@ -23,13 +23,12 @@
|
||||
|
||||
package com.iluwatar.abstractdocument.domain;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.iluwatar.abstractdocument.Document;
|
||||
import com.iluwatar.abstractdocument.domain.enums.Property;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* HasParts trait for static access to 'parts' property
|
||||
* HasParts trait for static access to 'parts' property.
|
||||
*/
|
||||
public interface HasParts extends Document {
|
||||
|
||||
|
@ -23,13 +23,12 @@
|
||||
|
||||
package com.iluwatar.abstractdocument.domain;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.iluwatar.abstractdocument.Document;
|
||||
import com.iluwatar.abstractdocument.domain.enums.Property;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* HasPrice trait for static access to 'price' property
|
||||
* HasPrice trait for static access to 'price' property.
|
||||
*/
|
||||
public interface HasPrice extends Document {
|
||||
|
||||
|
@ -23,13 +23,12 @@
|
||||
|
||||
package com.iluwatar.abstractdocument.domain;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.iluwatar.abstractdocument.Document;
|
||||
import com.iluwatar.abstractdocument.domain.enums.Property;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* HasType trait for static access to 'type' property
|
||||
* HasType trait for static access to 'type' property.
|
||||
*/
|
||||
public interface HasType extends Document {
|
||||
|
||||
|
@ -23,12 +23,11 @@
|
||||
|
||||
package com.iluwatar.abstractdocument.domain;
|
||||
|
||||
import com.iluwatar.abstractdocument.AbstractDocument;
|
||||
import java.util.Map;
|
||||
|
||||
import com.iluwatar.abstractdocument.AbstractDocument;
|
||||
|
||||
/**
|
||||
* Part entity
|
||||
* Part entity.
|
||||
*/
|
||||
public class Part extends AbstractDocument implements HasType, HasModel, HasPrice {
|
||||
|
||||
|
@ -24,9 +24,7 @@
|
||||
package com.iluwatar.abstractdocument.domain.enums;
|
||||
|
||||
/**
|
||||
*
|
||||
* Enum To Describe Property type
|
||||
*
|
||||
* Enum To Describe Property type.
|
||||
*/
|
||||
public enum Property {
|
||||
|
||||
|
Reference in New Issue
Block a user