diff --git a/abstract-factory/index.md b/abstract-factory/README.md similarity index 100% rename from abstract-factory/index.md rename to abstract-factory/README.md diff --git a/adapter/index.md b/adapter/README.md similarity index 100% rename from adapter/index.md rename to adapter/README.md diff --git a/async-method-invocation/index.md b/async-method-invocation/README.md similarity index 100% rename from async-method-invocation/index.md rename to async-method-invocation/README.md diff --git a/bridge/index.md b/bridge/README.md similarity index 100% rename from bridge/index.md rename to bridge/README.md diff --git a/builder/index.md b/builder/README.md similarity index 100% rename from builder/index.md rename to builder/README.md diff --git a/business-delegate/index.md b/business-delegate/README.md similarity index 100% rename from business-delegate/index.md rename to business-delegate/README.md diff --git a/caching/index.md b/caching/README.md similarity index 100% rename from caching/index.md rename to caching/README.md diff --git a/callback/index.md b/callback/README.md similarity index 100% rename from callback/index.md rename to callback/README.md diff --git a/chain/index.md b/chain/README.md similarity index 100% rename from chain/index.md rename to chain/README.md diff --git a/command/index.md b/command/README.md similarity index 100% rename from command/index.md rename to command/README.md diff --git a/composite/index.md b/composite/README.md similarity index 100% rename from composite/index.md rename to composite/README.md diff --git a/dao/index.md b/dao/README.md similarity index 100% rename from dao/index.md rename to dao/README.md diff --git a/decorator/index.md b/decorator/README.md similarity index 100% rename from decorator/index.md rename to decorator/README.md diff --git a/delegation/index.md b/delegation/README.md similarity index 100% rename from delegation/index.md rename to delegation/README.md diff --git a/dependency-injection/index.md b/dependency-injection/README.md similarity index 100% rename from dependency-injection/index.md rename to dependency-injection/README.md diff --git a/double-checked-locking/index.md b/double-checked-locking/README.md similarity index 100% rename from double-checked-locking/index.md rename to double-checked-locking/README.md diff --git a/double-dispatch/index.md b/double-dispatch/README.md similarity index 100% rename from double-dispatch/index.md rename to double-dispatch/README.md diff --git a/event-aggregator/index.md b/event-aggregator/README.md similarity index 100% rename from event-aggregator/index.md rename to event-aggregator/README.md diff --git a/event-driven-architecture/index.md b/event-driven-architecture/README.md similarity index 100% rename from event-driven-architecture/index.md rename to event-driven-architecture/README.md diff --git a/event-driven-architecture/etc/eda.png b/event-driven-architecture/etc/eda.png index 38c433a40..743726451 100644 Binary files a/event-driven-architecture/etc/eda.png and b/event-driven-architecture/etc/eda.png differ diff --git a/event-driven-architecture/etc/eda.ucls b/event-driven-architecture/etc/eda.ucls index 4ddb8b20c..776bedc81 100644 --- a/event-driven-architecture/etc/eda.ucls +++ b/event-driven-architecture/etc/eda.ucls @@ -4,7 +4,7 @@ - + @@ -15,7 +15,7 @@ project="event-driven-architecture" file="/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserUpdatedEventHandler.java" binary="false" corner="BOTTOM_RIGHT"> - + @@ -26,17 +26,17 @@ project="event-driven-architecture" file="/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserCreatedEventHandler.java" binary="false" corner="BOTTOM_RIGHT"> - + - - + @@ -46,7 +46,7 @@ - + @@ -56,7 +56,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -76,17 +76,17 @@ - + - - + @@ -94,99 +94,87 @@ - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - + + - - + - - - + + + - - + + - - + + - - - - + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + - - + + diff --git a/event-driven-architecture/src/main/java/com/iluwatar/eda/App.java b/event-driven-architecture/src/main/java/com/iluwatar/eda/App.java index 4179046c8..866b3c9e9 100644 --- a/event-driven-architecture/src/main/java/com/iluwatar/eda/App.java +++ b/event-driven-architecture/src/main/java/com/iluwatar/eda/App.java @@ -22,9 +22,9 @@ */ package com.iluwatar.eda; -import com.iluwatar.eda.event.Event; import com.iluwatar.eda.event.UserCreatedEvent; import com.iluwatar.eda.event.UserUpdatedEvent; +import com.iluwatar.eda.framework.Event; import com.iluwatar.eda.framework.EventDispatcher; import com.iluwatar.eda.handler.UserCreatedEventHandler; import com.iluwatar.eda.handler.UserUpdatedEventHandler; @@ -53,12 +53,12 @@ public class App { public static void main(String[] args) { EventDispatcher dispatcher = new EventDispatcher(); - dispatcher.registerChannel(UserCreatedEvent.class, new UserCreatedEventHandler()); - dispatcher.registerChannel(UserUpdatedEvent.class, new UserUpdatedEventHandler()); + dispatcher.registerHandler(UserCreatedEvent.class, new UserCreatedEventHandler()); + dispatcher.registerHandler(UserUpdatedEvent.class, new UserUpdatedEventHandler()); User user = new User("iluwatar"); - dispatcher.onEvent(new UserCreatedEvent(user)); - dispatcher.onEvent(new UserUpdatedEvent(user)); + dispatcher.dispatch(new UserCreatedEvent(user)); + dispatcher.dispatch(new UserUpdatedEvent(user)); } } diff --git a/event-driven-architecture/src/main/java/com/iluwatar/eda/event/Event.java b/event-driven-architecture/src/main/java/com/iluwatar/eda/event/AbstractEvent.java similarity index 85% rename from event-driven-architecture/src/main/java/com/iluwatar/eda/event/Event.java rename to event-driven-architecture/src/main/java/com/iluwatar/eda/event/AbstractEvent.java index 3ed0f9c9d..54a916c7b 100644 --- a/event-driven-architecture/src/main/java/com/iluwatar/eda/event/Event.java +++ b/event-driven-architecture/src/main/java/com/iluwatar/eda/event/AbstractEvent.java @@ -23,10 +23,10 @@ package com.iluwatar.eda.event; import com.iluwatar.eda.framework.EventDispatcher; -import com.iluwatar.eda.framework.Message; +import com.iluwatar.eda.framework.Event; /** - * The {@link Event} class serves as a base class for defining custom events happening with your + * The {@link AbstractEvent} class serves as a base class for defining custom events happening with your * system. In this example we have two types of events defined. *
    *
  • {@link UserCreatedEvent} - used when a user is created
  • @@ -34,16 +34,16 @@ import com.iluwatar.eda.framework.Message; *
* Events can be distinguished using the {@link #getType() getType} method. */ -public class Event implements Message { +public abstract class AbstractEvent implements Event { /** * Returns the event type as a {@link Class} object * In this example, this method is used by the {@link EventDispatcher} to * dispatch events depending on their type. * - * @return the Event type as a {@link Class}. + * @return the AbstractEvent type as a {@link Class}. */ - public Class getType() { + public Class getType() { return getClass(); } } \ No newline at end of file diff --git a/event-driven-architecture/src/main/java/com/iluwatar/eda/event/UserCreatedEvent.java b/event-driven-architecture/src/main/java/com/iluwatar/eda/event/UserCreatedEvent.java index e3354aaf2..717ed1a9d 100644 --- a/event-driven-architecture/src/main/java/com/iluwatar/eda/event/UserCreatedEvent.java +++ b/event-driven-architecture/src/main/java/com/iluwatar/eda/event/UserCreatedEvent.java @@ -29,7 +29,7 @@ import com.iluwatar.eda.model.User; * This class can be extended to contain details about the user has been created. In this example, * the entire {@link User} object is passed on as data with the event. */ -public class UserCreatedEvent extends Event { +public class UserCreatedEvent extends AbstractEvent { private User user; diff --git a/event-driven-architecture/src/main/java/com/iluwatar/eda/event/UserUpdatedEvent.java b/event-driven-architecture/src/main/java/com/iluwatar/eda/event/UserUpdatedEvent.java index 37ca05932..9646957dc 100644 --- a/event-driven-architecture/src/main/java/com/iluwatar/eda/event/UserUpdatedEvent.java +++ b/event-driven-architecture/src/main/java/com/iluwatar/eda/event/UserUpdatedEvent.java @@ -29,7 +29,7 @@ import com.iluwatar.eda.model.User; * This class can be extended to contain details about the user has been updated. In this example, * the entire {@link User} object is passed on as data with the event. */ -public class UserUpdatedEvent extends Event { +public class UserUpdatedEvent extends AbstractEvent { private User user; diff --git a/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Message.java b/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Event.java similarity index 91% rename from event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Message.java rename to event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Event.java index ee9c48965..c63d2746f 100644 --- a/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Message.java +++ b/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Event.java @@ -23,15 +23,15 @@ package com.iluwatar.eda.framework; /** - * A {@link Message} is an object with a specific type that is associated + * A {@link Event} is an object with a specific type that is associated * to a specific {@link Handler}. */ -public interface Message { +public interface Event { /** * Returns the message type as a {@link Class} object. In this example the message type is * used to handle events by their type. * @return the message type as a {@link Class}. */ - Class getType(); + Class getType(); } diff --git a/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/EventDispatcher.java b/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/EventDispatcher.java index 69e2cf0e3..9f8e29315 100644 --- a/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/EventDispatcher.java +++ b/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/EventDispatcher.java @@ -22,19 +22,16 @@ */ package com.iluwatar.eda.framework; -import com.iluwatar.eda.event.Event; - import java.util.HashMap; import java.util.Map; /** * Handles the routing of {@link Event} messages to associated handlers. * A {@link HashMap} is used to store the association between events and their respective handlers. - * */ public class EventDispatcher { - private Map, Handler> handlers; + private Map, Handler> handlers; public EventDispatcher() { handlers = new HashMap<>(); @@ -46,8 +43,8 @@ public class EventDispatcher { * @param eventType The {@link Event} to be registered * @param handler The {@link Handler} that will be handling the {@link Event} */ - public void registerChannel(Class eventType, - Handler handler) { + public void registerHandler(Class eventType, + Handler handler) { handlers.put(eventType, handler); } @@ -56,8 +53,12 @@ public class EventDispatcher { * * @param event The {@link Event} to be dispatched */ - public void onEvent(Event event) { - handlers.get(event.getClass()).onEvent(event); + @SuppressWarnings("unchecked") + public void dispatch(E event) { + Handler handler = (Handler) handlers.get(event.getClass()); + if (handler != null) { + handler.onEvent(event); + } } } \ No newline at end of file diff --git a/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Handler.java b/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Handler.java index 9c800a4d4..44bdab6dc 100644 --- a/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Handler.java +++ b/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Handler.java @@ -22,13 +22,11 @@ */ package com.iluwatar.eda.framework; -import com.iluwatar.eda.event.Event; - /** * This interface can be implemented to handle different types of messages. * Every handler is responsible for a single of type message */ -public interface Handler { +public interface Handler { /** * The onEvent method should implement and handle behavior related to the event. @@ -36,5 +34,5 @@ public interface Handler { * a queue to be consumed by other sub systems. * @param event the {@link Event} object to be handled. */ - void onEvent(Event event); + void onEvent(E event); } \ No newline at end of file diff --git a/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserCreatedEventHandler.java b/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserCreatedEventHandler.java index c51b3391a..3ef4e8255 100644 --- a/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserCreatedEventHandler.java +++ b/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserCreatedEventHandler.java @@ -22,7 +22,6 @@ */ package com.iluwatar.eda.handler; -import com.iluwatar.eda.event.Event; import com.iluwatar.eda.event.UserCreatedEvent; import com.iluwatar.eda.framework.Handler; @@ -32,9 +31,10 @@ import com.iluwatar.eda.framework.Handler; public class UserCreatedEventHandler implements Handler { @Override - public void onEvent(Event message) { + public void onEvent(UserCreatedEvent event) { - UserCreatedEvent userCreatedEvent = (UserCreatedEvent) message; - System.out.printf("User with %s has been Created!", userCreatedEvent.getUser().getUsername()); + System.out.println(String.format( + "User '%s' has been Created!", event.getUser().getUsername())); } + } diff --git a/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserUpdatedEventHandler.java b/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserUpdatedEventHandler.java index 5be4ab5cc..0311d5781 100644 --- a/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserUpdatedEventHandler.java +++ b/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserUpdatedEventHandler.java @@ -22,7 +22,6 @@ */ package com.iluwatar.eda.handler; -import com.iluwatar.eda.event.Event; import com.iluwatar.eda.event.UserUpdatedEvent; import com.iluwatar.eda.framework.Handler; @@ -32,9 +31,9 @@ import com.iluwatar.eda.framework.Handler; public class UserUpdatedEventHandler implements Handler { @Override - public void onEvent(Event message) { + public void onEvent(UserUpdatedEvent event) { - UserUpdatedEvent userUpdatedEvent = (UserUpdatedEvent) message; - System.out.printf("User with %s has been Updated!", userUpdatedEvent.getUser().getUsername()); + System.out.println(String.format( + "User '%s' has been Updated!", event.getUser().getUsername())); } } diff --git a/event-driven-architecture/src/test/java/com/iluwatar/eda/event/UserCreatedEventTest.java b/event-driven-architecture/src/test/java/com/iluwatar/eda/event/UserCreatedEventTest.java index 754fac678..b9074faf2 100644 --- a/event-driven-architecture/src/test/java/com/iluwatar/eda/event/UserCreatedEventTest.java +++ b/event-driven-architecture/src/test/java/com/iluwatar/eda/event/UserCreatedEventTest.java @@ -29,13 +29,13 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; /** - * {@link UserCreatedEventTest} tests and verifies {@link Event} behaviour. + * {@link UserCreatedEventTest} tests and verifies {@link AbstractEvent} behaviour. */ public class UserCreatedEventTest { /** - * This unit test should correctly return the {@link Event} class type when calling the - * {@link Event#getType() getType} method. + * This unit test should correctly return the {@link AbstractEvent} class type when calling the + * {@link AbstractEvent#getType() getType} method. */ @Test public void testGetEventType() { diff --git a/event-driven-architecture/src/test/java/com/iluwatar/eda/framework/EventDispatcherTest.java b/event-driven-architecture/src/test/java/com/iluwatar/eda/framework/EventDispatcherTest.java index 8db315ff4..21956afec 100644 --- a/event-driven-architecture/src/test/java/com/iluwatar/eda/framework/EventDispatcherTest.java +++ b/event-driven-architecture/src/test/java/com/iluwatar/eda/framework/EventDispatcherTest.java @@ -22,7 +22,6 @@ */ package com.iluwatar.eda.framework; -import com.iluwatar.eda.framework.EventDispatcher; import com.iluwatar.eda.event.UserCreatedEvent; import com.iluwatar.eda.event.UserUpdatedEvent; import com.iluwatar.eda.handler.UserCreatedEventHandler; @@ -49,8 +48,8 @@ public class EventDispatcherTest { EventDispatcher dispatcher = spy(new EventDispatcher()); UserCreatedEventHandler userCreatedEventHandler = spy(new UserCreatedEventHandler()); UserUpdatedEventHandler userUpdatedEventHandler = spy(new UserUpdatedEventHandler()); - dispatcher.registerChannel(UserCreatedEvent.class, userCreatedEventHandler); - dispatcher.registerChannel(UserUpdatedEvent.class, userUpdatedEventHandler); + dispatcher.registerHandler(UserCreatedEvent.class, userCreatedEventHandler); + dispatcher.registerHandler(UserUpdatedEvent.class, userUpdatedEventHandler); User user = new User("iluwatar"); @@ -58,15 +57,14 @@ public class EventDispatcherTest { UserUpdatedEvent userUpdatedEvent = new UserUpdatedEvent(user); //fire a userCreatedEvent and verify that userCreatedEventHandler has been invoked. - dispatcher.onEvent(userCreatedEvent); + dispatcher.dispatch(userCreatedEvent); verify(userCreatedEventHandler).onEvent(userCreatedEvent); - verify(dispatcher).onEvent(userCreatedEvent); + verify(dispatcher).dispatch(userCreatedEvent); //fire a userCreatedEvent and verify that userUpdatedEventHandler has been invoked. - dispatcher.onEvent(userUpdatedEvent); + dispatcher.dispatch(userUpdatedEvent); verify(userUpdatedEventHandler).onEvent(userUpdatedEvent); - verify(dispatcher).onEvent(userUpdatedEvent); + verify(dispatcher).dispatch(userUpdatedEvent); } - } diff --git a/execute-around/index.md b/execute-around/README.md similarity index 100% rename from execute-around/index.md rename to execute-around/README.md diff --git a/facade/index.md b/facade/README.md similarity index 100% rename from facade/index.md rename to facade/README.md diff --git a/facade/src/main/java/com/iluwatar/facade/DwarvenGoldmineFacade.java b/facade/src/main/java/com/iluwatar/facade/DwarvenGoldmineFacade.java index 9e3aa29c3..4f6e3be4c 100644 --- a/facade/src/main/java/com/iluwatar/facade/DwarvenGoldmineFacade.java +++ b/facade/src/main/java/com/iluwatar/facade/DwarvenGoldmineFacade.java @@ -60,7 +60,7 @@ public class DwarvenGoldmineFacade { makeActions(workers, DwarvenMineWorker.Action.GO_HOME, DwarvenMineWorker.Action.GO_TO_SLEEP); } - private void makeActions(Collection workers, + private static void makeActions(Collection workers, DwarvenMineWorker.Action... actions) { for (DwarvenMineWorker worker : workers) { worker.action(actions); diff --git a/factory-kit/index.md b/factory-kit/README.md similarity index 100% rename from factory-kit/index.md rename to factory-kit/README.md diff --git a/factory-kit/src/main/java/com/iluwatar/factorykit/App.java b/factory-kit/src/main/java/com/iluwatar/factorykit/App.java index 91d1eb061..f27bee170 100644 --- a/factory-kit/src/main/java/com/iluwatar/factorykit/App.java +++ b/factory-kit/src/main/java/com/iluwatar/factorykit/App.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.factorykit; /** diff --git a/factory-kit/src/main/java/com/iluwatar/factorykit/Axe.java b/factory-kit/src/main/java/com/iluwatar/factorykit/Axe.java index 4e1a5e554..826a1f9ec 100644 --- a/factory-kit/src/main/java/com/iluwatar/factorykit/Axe.java +++ b/factory-kit/src/main/java/com/iluwatar/factorykit/Axe.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.factorykit; public class Axe implements Weapon { diff --git a/factory-kit/src/main/java/com/iluwatar/factorykit/Bow.java b/factory-kit/src/main/java/com/iluwatar/factorykit/Bow.java index a90f4cf2e..5aa952c3d 100644 --- a/factory-kit/src/main/java/com/iluwatar/factorykit/Bow.java +++ b/factory-kit/src/main/java/com/iluwatar/factorykit/Bow.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.factorykit; public class Bow implements Weapon { diff --git a/factory-kit/src/main/java/com/iluwatar/factorykit/Builder.java b/factory-kit/src/main/java/com/iluwatar/factorykit/Builder.java index be74626f7..1049c7b6f 100644 --- a/factory-kit/src/main/java/com/iluwatar/factorykit/Builder.java +++ b/factory-kit/src/main/java/com/iluwatar/factorykit/Builder.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.factorykit; import java.util.function.Supplier; diff --git a/factory-kit/src/main/java/com/iluwatar/factorykit/Spear.java b/factory-kit/src/main/java/com/iluwatar/factorykit/Spear.java index a50f54290..c32811e8c 100644 --- a/factory-kit/src/main/java/com/iluwatar/factorykit/Spear.java +++ b/factory-kit/src/main/java/com/iluwatar/factorykit/Spear.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.factorykit; public class Spear implements Weapon { diff --git a/factory-kit/src/main/java/com/iluwatar/factorykit/Sword.java b/factory-kit/src/main/java/com/iluwatar/factorykit/Sword.java index 278febaf5..208cd6bbb 100644 --- a/factory-kit/src/main/java/com/iluwatar/factorykit/Sword.java +++ b/factory-kit/src/main/java/com/iluwatar/factorykit/Sword.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.factorykit; public class Sword implements Weapon { diff --git a/factory-kit/src/main/java/com/iluwatar/factorykit/Weapon.java b/factory-kit/src/main/java/com/iluwatar/factorykit/Weapon.java index 980a2219f..3d668e352 100644 --- a/factory-kit/src/main/java/com/iluwatar/factorykit/Weapon.java +++ b/factory-kit/src/main/java/com/iluwatar/factorykit/Weapon.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.factorykit; /** diff --git a/factory-kit/src/main/java/com/iluwatar/factorykit/WeaponFactory.java b/factory-kit/src/main/java/com/iluwatar/factorykit/WeaponFactory.java index e83a997c6..80a6fd9d3 100644 --- a/factory-kit/src/main/java/com/iluwatar/factorykit/WeaponFactory.java +++ b/factory-kit/src/main/java/com/iluwatar/factorykit/WeaponFactory.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.factorykit; import java.util.HashMap; diff --git a/factory-kit/src/main/java/com/iluwatar/factorykit/WeaponType.java b/factory-kit/src/main/java/com/iluwatar/factorykit/WeaponType.java index ac542048d..283f252de 100644 --- a/factory-kit/src/main/java/com/iluwatar/factorykit/WeaponType.java +++ b/factory-kit/src/main/java/com/iluwatar/factorykit/WeaponType.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.factorykit; /** diff --git a/factory-kit/src/test/java/com/iluwatar/factorykit/app/AppTest.java b/factory-kit/src/test/java/com/iluwatar/factorykit/app/AppTest.java index 9b9af2530..036326d97 100644 --- a/factory-kit/src/test/java/com/iluwatar/factorykit/app/AppTest.java +++ b/factory-kit/src/test/java/com/iluwatar/factorykit/app/AppTest.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.factorykit.app; import com.iluwatar.factorykit.App; diff --git a/factory-kit/src/test/java/com/iluwatar/factorykit/factorykit/FactoryKitTest.java b/factory-kit/src/test/java/com/iluwatar/factorykit/factorykit/FactoryKitTest.java index ea629f57d..c57bee3e3 100644 --- a/factory-kit/src/test/java/com/iluwatar/factorykit/factorykit/FactoryKitTest.java +++ b/factory-kit/src/test/java/com/iluwatar/factorykit/factorykit/FactoryKitTest.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.factorykit.factorykit; import com.iluwatar.factorykit.*; diff --git a/factory-method/index.md b/factory-method/README.md similarity index 100% rename from factory-method/index.md rename to factory-method/README.md diff --git a/feature-toggle/index.md b/feature-toggle/README.md similarity index 100% rename from feature-toggle/index.md rename to feature-toggle/README.md diff --git a/fluentinterface/index.md b/fluentinterface/README.md similarity index 100% rename from fluentinterface/index.md rename to fluentinterface/README.md diff --git a/flux/index.md b/flux/README.md similarity index 100% rename from flux/index.md rename to flux/README.md diff --git a/flyweight/index.md b/flyweight/README.md similarity index 100% rename from flyweight/index.md rename to flyweight/README.md diff --git a/front-controller/index.md b/front-controller/README.md similarity index 100% rename from front-controller/index.md rename to front-controller/README.md diff --git a/front-controller/src/main/java/com/iluwatar/front/controller/FrontController.java b/front-controller/src/main/java/com/iluwatar/front/controller/FrontController.java index f5537c39b..6e2cccb0f 100644 --- a/front-controller/src/main/java/com/iluwatar/front/controller/FrontController.java +++ b/front-controller/src/main/java/com/iluwatar/front/controller/FrontController.java @@ -44,7 +44,7 @@ public class FrontController { } } - private Class getCommandClass(String request) { + private static Class getCommandClass(String request) { Class result; try { result = Class.forName("com.iluwatar.front.controller." + request + "Command"); diff --git a/half-sync-half-async/index.md b/half-sync-half-async/README.md similarity index 100% rename from half-sync-half-async/index.md rename to half-sync-half-async/README.md diff --git a/intercepting-filter/index.md b/intercepting-filter/README.md similarity index 100% rename from intercepting-filter/index.md rename to intercepting-filter/README.md diff --git a/interpreter/index.md b/interpreter/README.md similarity index 100% rename from interpreter/index.md rename to interpreter/README.md diff --git a/iterator/index.md b/iterator/README.md similarity index 100% rename from iterator/index.md rename to iterator/README.md diff --git a/layers/index.md b/layers/README.md similarity index 100% rename from layers/index.md rename to layers/README.md diff --git a/lazy-loading/index.md b/lazy-loading/README.md similarity index 100% rename from lazy-loading/index.md rename to lazy-loading/README.md diff --git a/mediator/index.md b/mediator/README.md similarity index 100% rename from mediator/index.md rename to mediator/README.md diff --git a/memento/index.md b/memento/README.md similarity index 100% rename from memento/index.md rename to memento/README.md diff --git a/message-channel/index.md b/message-channel/README.md similarity index 100% rename from message-channel/index.md rename to message-channel/README.md diff --git a/model-view-controller/index.md b/model-view-controller/README.md similarity index 100% rename from model-view-controller/index.md rename to model-view-controller/README.md diff --git a/model-view-presenter/index.md b/model-view-presenter/README.md similarity index 100% rename from model-view-presenter/index.md rename to model-view-presenter/README.md diff --git a/monad/index.md b/monad/README.md similarity index 97% rename from monad/index.md rename to monad/README.md index 82deba922..ffc67a354 100644 --- a/monad/index.md +++ b/monad/README.md @@ -1,35 +1,35 @@ ---- -layout: pattern -title: Monad -folder: monad -permalink: /patterns/monad/ -categories: Other -tags: - - Java - - Difficulty-Advanced - - Functional ---- - -## Intent - -Monad pattern based on monad from linear algebra represents the way of chaining operations -together step by step. Binding functions can be described as passing one's output to another's input -basing on the 'same type' contract. Formally, monad consists of a type constructor M and two -operations: -bind - that takes monadic object and a function from plain object to monadic value and returns monadic value -return - that takes plain type object and returns this object wrapped in a monadic value. - -![alt text](./etc/monad.png "Monad") - -## Applicability - -Use the Monad in any of the following situations - -* when you want to chain operations easily -* when you want to apply each function regardless of the result of any of them - -## Credits - -* [Design Pattern Reloaded by Remi Forax](https://youtu.be/-k2X7guaArU) -* [Brian Beckman: Don't fear the Monad](https://channel9.msdn.com/Shows/Going+Deep/Brian-Beckman-Dont-fear-the-Monads) +--- +layout: pattern +title: Monad +folder: monad +permalink: /patterns/monad/ +categories: Other +tags: + - Java + - Difficulty-Advanced + - Functional +--- + +## Intent + +Monad pattern based on monad from linear algebra represents the way of chaining operations +together step by step. Binding functions can be described as passing one's output to another's input +basing on the 'same type' contract. Formally, monad consists of a type constructor M and two +operations: +bind - that takes monadic object and a function from plain object to monadic value and returns monadic value +return - that takes plain type object and returns this object wrapped in a monadic value. + +![alt text](./etc/monad.png "Monad") + +## Applicability + +Use the Monad in any of the following situations + +* when you want to chain operations easily +* when you want to apply each function regardless of the result of any of them + +## Credits + +* [Design Pattern Reloaded by Remi Forax](https://youtu.be/-k2X7guaArU) +* [Brian Beckman: Don't fear the Monad](https://channel9.msdn.com/Shows/Going+Deep/Brian-Beckman-Dont-fear-the-Monads) * [Monad on Wikipedia](https://en.wikipedia.org/wiki/Monad_(functional_programming)) \ No newline at end of file diff --git a/monad/src/main/java/com/iluwatar/monad/App.java b/monad/src/main/java/com/iluwatar/monad/App.java index e330cfa64..7b28fdcf8 100644 --- a/monad/src/main/java/com/iluwatar/monad/App.java +++ b/monad/src/main/java/com/iluwatar/monad/App.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monad; import java.util.Objects; diff --git a/monad/src/main/java/com/iluwatar/monad/Sex.java b/monad/src/main/java/com/iluwatar/monad/Sex.java index 8b7e43f3c..b5d094d4b 100644 --- a/monad/src/main/java/com/iluwatar/monad/Sex.java +++ b/monad/src/main/java/com/iluwatar/monad/Sex.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monad; public enum Sex { diff --git a/monad/src/main/java/com/iluwatar/monad/User.java b/monad/src/main/java/com/iluwatar/monad/User.java index edd299643..471094526 100644 --- a/monad/src/main/java/com/iluwatar/monad/User.java +++ b/monad/src/main/java/com/iluwatar/monad/User.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monad; public class User { diff --git a/monad/src/main/java/com/iluwatar/monad/Validator.java b/monad/src/main/java/com/iluwatar/monad/Validator.java index 2298a4d8e..cc4f36020 100644 --- a/monad/src/main/java/com/iluwatar/monad/Validator.java +++ b/monad/src/main/java/com/iluwatar/monad/Validator.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monad; import java.util.ArrayList; diff --git a/monad/src/test/java/com/iluwatar/monad/AppTest.java b/monad/src/test/java/com/iluwatar/monad/AppTest.java index 5d23b41a6..78440b468 100644 --- a/monad/src/test/java/com/iluwatar/monad/AppTest.java +++ b/monad/src/test/java/com/iluwatar/monad/AppTest.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monad; import org.junit.Test; diff --git a/monad/src/test/java/com/iluwatar/monad/MonadTest.java b/monad/src/test/java/com/iluwatar/monad/MonadTest.java index ae78572f8..4ada7191d 100644 --- a/monad/src/test/java/com/iluwatar/monad/MonadTest.java +++ b/monad/src/test/java/com/iluwatar/monad/MonadTest.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monad; diff --git a/monostate/index.md b/monostate/README.md similarity index 100% rename from monostate/index.md rename to monostate/README.md diff --git a/multiton/index.md b/multiton/README.md similarity index 100% rename from multiton/index.md rename to multiton/README.md diff --git a/naked-objects/index.md b/naked-objects/README.md similarity index 100% rename from naked-objects/index.md rename to naked-objects/README.md diff --git a/null-object/index.md b/null-object/README.md similarity index 100% rename from null-object/index.md rename to null-object/README.md diff --git a/object-pool/index.md b/object-pool/README.md similarity index 100% rename from object-pool/index.md rename to object-pool/README.md diff --git a/observer/index.md b/observer/README.md similarity index 100% rename from observer/index.md rename to observer/README.md diff --git a/poison-pill/index.md b/poison-pill/README.md similarity index 100% rename from poison-pill/index.md rename to poison-pill/README.md diff --git a/private-class-data/index.md b/private-class-data/README.md similarity index 100% rename from private-class-data/index.md rename to private-class-data/README.md diff --git a/producer-consumer/index.md b/producer-consumer/README.md similarity index 100% rename from producer-consumer/index.md rename to producer-consumer/README.md diff --git a/property/index.md b/property/README.md similarity index 100% rename from property/index.md rename to property/README.md diff --git a/prototype/index.md b/prototype/README.md similarity index 100% rename from prototype/index.md rename to prototype/README.md diff --git a/proxy/index.md b/proxy/README.md similarity index 100% rename from proxy/index.md rename to proxy/README.md diff --git a/publish-subscribe/index.md b/publish-subscribe/README.md similarity index 100% rename from publish-subscribe/index.md rename to publish-subscribe/README.md diff --git a/reactor/index.md b/reactor/README.md similarity index 100% rename from reactor/index.md rename to reactor/README.md diff --git a/reactor/src/main/java/com/iluwatar/reactor/app/LoggingHandler.java b/reactor/src/main/java/com/iluwatar/reactor/app/LoggingHandler.java index e2b02e445..ab2bcfb1a 100644 --- a/reactor/src/main/java/com/iluwatar/reactor/app/LoggingHandler.java +++ b/reactor/src/main/java/com/iluwatar/reactor/app/LoggingHandler.java @@ -58,7 +58,7 @@ public class LoggingHandler implements ChannelHandler { } } - private void sendReply(AbstractNioChannel channel, DatagramPacket incomingPacket, SelectionKey key) { + private static void sendReply(AbstractNioChannel channel, DatagramPacket incomingPacket, SelectionKey key) { /* * Create a reply acknowledgement datagram packet setting the receiver to the sender of incoming * message. @@ -69,12 +69,12 @@ public class LoggingHandler implements ChannelHandler { channel.write(replyPacket, key); } - private void sendReply(AbstractNioChannel channel, SelectionKey key) { + private static void sendReply(AbstractNioChannel channel, SelectionKey key) { ByteBuffer buffer = ByteBuffer.wrap(ACK); channel.write(buffer, key); } - private void doLogging(ByteBuffer data) { + private static void doLogging(ByteBuffer data) { // assuming UTF-8 :( System.out.println(new String(data.array(), 0, data.limit())); } diff --git a/reactor/src/main/java/com/iluwatar/reactor/framework/NioReactor.java b/reactor/src/main/java/com/iluwatar/reactor/framework/NioReactor.java index 716f88801..3d5ebf5a0 100644 --- a/reactor/src/main/java/com/iluwatar/reactor/framework/NioReactor.java +++ b/reactor/src/main/java/com/iluwatar/reactor/framework/NioReactor.java @@ -186,7 +186,7 @@ public class NioReactor { } } - private void onChannelWritable(SelectionKey key) throws IOException { + private static void onChannelWritable(SelectionKey key) throws IOException { AbstractNioChannel channel = (AbstractNioChannel) key.attachment(); channel.flush(key); } diff --git a/reader-writer-lock/index.md b/reader-writer-lock/README.md similarity index 100% rename from reader-writer-lock/index.md rename to reader-writer-lock/README.md diff --git a/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/ReaderWriterLock.java b/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/ReaderWriterLock.java index c8f59edd5..f08ed805d 100644 --- a/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/ReaderWriterLock.java +++ b/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/ReaderWriterLock.java @@ -89,7 +89,7 @@ public class ReaderWriterLock implements ReadWriteLock { return globalMutex.isEmpty(); } - private void waitUninterruptibly(Object o) { + private static void waitUninterruptibly(Object o) { try { o.wait(); } catch (InterruptedException e) { diff --git a/repository/index.md b/repository/README.md similarity index 100% rename from repository/index.md rename to repository/README.md diff --git a/repository/src/main/java/com/iluwatar/repository/AppConfig.java b/repository/src/main/java/com/iluwatar/repository/AppConfig.java index 285ecfbfe..3e7093358 100644 --- a/repository/src/main/java/com/iluwatar/repository/AppConfig.java +++ b/repository/src/main/java/com/iluwatar/repository/AppConfig.java @@ -76,7 +76,7 @@ public class AppConfig { /** * Properties for Jpa */ - private Properties jpaProperties() { + private static Properties jpaProperties() { Properties properties = new Properties(); properties.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect"); properties.setProperty("hibernate.hbm2ddl.auto", "create-drop"); diff --git a/resource-acquisition-is-initialization/index.md b/resource-acquisition-is-initialization/README.md similarity index 100% rename from resource-acquisition-is-initialization/index.md rename to resource-acquisition-is-initialization/README.md diff --git a/servant/index.md b/servant/README.md similarity index 100% rename from servant/index.md rename to servant/README.md diff --git a/service-layer/index.md b/service-layer/README.md similarity index 100% rename from service-layer/index.md rename to service-layer/README.md diff --git a/service-locator/index.md b/service-locator/README.md similarity index 100% rename from service-locator/index.md rename to service-locator/README.md diff --git a/singleton/index.md b/singleton/README.md similarity index 100% rename from singleton/index.md rename to singleton/README.md diff --git a/specification/index.md b/specification/README.md similarity index 100% rename from specification/index.md rename to specification/README.md diff --git a/state/index.md b/state/README.md similarity index 100% rename from state/index.md rename to state/README.md diff --git a/step-builder/index.md b/step-builder/README.md similarity index 100% rename from step-builder/index.md rename to step-builder/README.md diff --git a/strategy/index.md b/strategy/README.md similarity index 100% rename from strategy/index.md rename to strategy/README.md diff --git a/template-method/index.md b/template-method/README.md similarity index 100% rename from template-method/index.md rename to template-method/README.md diff --git a/thread-pool/index.md b/thread-pool/README.md similarity index 100% rename from thread-pool/index.md rename to thread-pool/README.md diff --git a/tolerant-reader/index.md b/tolerant-reader/README.md similarity index 100% rename from tolerant-reader/index.md rename to tolerant-reader/README.md diff --git a/twin/index.md b/twin/README.md similarity index 100% rename from twin/index.md rename to twin/README.md diff --git a/value-object/index.md b/value-object/README.md similarity index 100% rename from value-object/index.md rename to value-object/README.md diff --git a/value-object/pom.xml b/value-object/pom.xml index 1ed2adb43..3cbb7bb86 100644 --- a/value-object/pom.xml +++ b/value-object/pom.xml @@ -1,4 +1,28 @@ + diff --git a/value-object/src/main/java/com/iluwatar/value/object/App.java b/value-object/src/main/java/com/iluwatar/value/object/App.java index 85779fcb7..1e943d054 100644 --- a/value-object/src/main/java/com/iluwatar/value/object/App.java +++ b/value-object/src/main/java/com/iluwatar/value/object/App.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.value.object; /** diff --git a/value-object/src/main/java/com/iluwatar/value/object/HeroStat.java b/value-object/src/main/java/com/iluwatar/value/object/HeroStat.java index 101837db0..258c4d6a0 100644 --- a/value-object/src/main/java/com/iluwatar/value/object/HeroStat.java +++ b/value-object/src/main/java/com/iluwatar/value/object/HeroStat.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.value.object; /** diff --git a/value-object/src/test/java/com/iluwatar/value/object/AppTest.java b/value-object/src/test/java/com/iluwatar/value/object/AppTest.java index aed3c2f20..85ef8b84e 100644 --- a/value-object/src/test/java/com/iluwatar/value/object/AppTest.java +++ b/value-object/src/test/java/com/iluwatar/value/object/AppTest.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.value.object; import org.junit.Test; diff --git a/value-object/src/test/java/com/iluwatar/value/object/HeroStatTest.java b/value-object/src/test/java/com/iluwatar/value/object/HeroStatTest.java index 785a4d8fe..4a8034b0b 100644 --- a/value-object/src/test/java/com/iluwatar/value/object/HeroStatTest.java +++ b/value-object/src/test/java/com/iluwatar/value/object/HeroStatTest.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.value.object; import static org.hamcrest.CoreMatchers.is; diff --git a/visitor/index.md b/visitor/README.md similarity index 100% rename from visitor/index.md rename to visitor/README.md