chore: remove default Maven and Gradle project files
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* This source file was generated by the Gradle 'init' task
|
||||
*/
|
||||
package org.example;
|
||||
|
||||
import org.example.adapter.*;
|
||||
import org.example.builder.*;
|
||||
import org.example.chain.*;
|
||||
import org.example.decorator.*;
|
||||
import org.example.proxy.*;
|
||||
import org.example.strategy.*;
|
||||
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
run();
|
||||
}
|
||||
|
||||
private static void run() {
|
||||
checkAdapterPattern();
|
||||
|
||||
checkBuilderPattern();
|
||||
|
||||
checkChainPattern();
|
||||
|
||||
checkDecoratorPattern();
|
||||
|
||||
checkProxyPattern();
|
||||
|
||||
checkStrategyPattern();
|
||||
}
|
||||
|
||||
private static void checkAdapterPattern() {
|
||||
Adaptee adaptee = new Adaptee();
|
||||
Target target = new Adapter(adaptee);
|
||||
|
||||
target.methodWithoutArguments();
|
||||
}
|
||||
|
||||
private static void checkBuilderPattern() {
|
||||
Product product =
|
||||
new ProductBuilder().setFirst("first").setSecond("second").setThird(3).build();
|
||||
|
||||
System.out.println(product);
|
||||
}
|
||||
|
||||
private static void checkChainPattern() {
|
||||
Handler handler = new ConcreteHandlerA();
|
||||
handler.setNext(new ConcreteHandlerB());
|
||||
|
||||
handler.handle(42);
|
||||
handler.handle("Hello");
|
||||
}
|
||||
|
||||
private static void checkDecoratorPattern() {
|
||||
Component component = new ConcreteComponent();
|
||||
Component decorator = new ConcreteDecorator(component);
|
||||
|
||||
decorator.operation();
|
||||
}
|
||||
|
||||
private static void checkProxyPattern() {
|
||||
Service service = new ConcreteService();
|
||||
Service proxy = new ServiceProxy(service);
|
||||
|
||||
proxy.execute();
|
||||
}
|
||||
|
||||
private static void checkStrategyPattern() {
|
||||
Context context = new Context(new ConcreteStrategyA());
|
||||
|
||||
boolean crayfishWhistled = true; // Если рак на горе свистнул
|
||||
|
||||
if (crayfishWhistled) {
|
||||
context.setStrategy(new ConcreteStrategyB());
|
||||
}
|
||||
|
||||
context.executeStrategy();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user