├── .gitignore
├── IoC
└── .idea
│ └── workspace.xml
├── OOP-SOLID
├── .idea
│ ├── .gitignore
│ ├── compiler.xml
│ ├── jarRepositories.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── runConfigurations.xml
│ ├── sonarlint
│ │ └── issuestore
│ │ │ ├── 0
│ │ │ ├── 0
│ │ │ │ └── 0027c168f7e900e7ed7f3e48e4080f85b1e6fffa
│ │ │ ├── 6
│ │ │ │ ├── 06205613f9bed6cb87024c9ab3fc22a1f574d1d7
│ │ │ │ └── 062bb33dd249ddd09565cf350099ba65827ae161
│ │ │ └── b
│ │ │ │ └── 0bfa9855144eeb26e50e5f86000263c17ac65fd8
│ │ │ ├── 1
│ │ │ ├── 0
│ │ │ │ └── 1005d45cec92b04aae10302b0e30b1b7bb6e172c
│ │ │ ├── 3
│ │ │ │ └── 132b235240c4e5475a36b9c6d5be7119e0ae0dbb
│ │ │ ├── 6
│ │ │ │ └── 169c302b28e8c71f1747845698ae30a1e0b956a5
│ │ │ ├── 9
│ │ │ │ └── 19a329d20b9bad9656ee7b1712ddf28c1df0adbf
│ │ │ └── e
│ │ │ │ └── 1eff4bb119bd9cd888b0975b06d8c6a62e68f893
│ │ │ ├── 2
│ │ │ ├── 0
│ │ │ │ └── 205e59c9f3da8d1262760dcaf3a0c4daee5098d5
│ │ │ ├── 1
│ │ │ │ └── 217fc70d99b8bb8cabf6b542a91e2172132f06c1
│ │ │ ├── 4
│ │ │ │ └── 24f35fd1817c2613169eec96a357d7c3983ee6a8
│ │ │ ├── 6
│ │ │ │ └── 2622e5c76da42dcaea6f9bbd9d39b875677381d7
│ │ │ ├── 7
│ │ │ │ └── 273720983f5f04ac2a907602142dc4da4fda1fd1
│ │ │ ├── 8
│ │ │ │ └── 284b590176f0c342282a48b0e208aefd7026169d
│ │ │ ├── 9
│ │ │ │ └── 2956a1247823b52c76b503eb1beccd6c4daee3fb
│ │ │ └── b
│ │ │ │ └── 2bdd6f3ec77f7eccf104c87f23a657b01de8e3ed
│ │ │ ├── 3
│ │ │ ├── 5
│ │ │ │ └── 35fa1e39a2d68dbeb4c3ee041c1ef87e04fda7f2
│ │ │ ├── b
│ │ │ │ └── 3b4482329013953eca7bb226a6807ebe4fa9f609
│ │ │ └── d
│ │ │ │ └── 3dbfd2d614e5109b2fd39362f3ae69006a0a87f6
│ │ │ ├── 4
│ │ │ ├── 3
│ │ │ │ └── 43a0d03ebf4aba57a6e52d3223178444953e882b
│ │ │ ├── 4
│ │ │ │ └── 442292b8a7efeabbe4cc176709b833b1792140ec
│ │ │ ├── c
│ │ │ │ └── 4c220f465d49e57892b9db8eab1958ccd637a049
│ │ │ └── e
│ │ │ │ └── 4edeca64a2c69a3e6dce7685201bc494f33b7009
│ │ │ ├── 5
│ │ │ ├── 8
│ │ │ │ └── 58ab0fbaf9eeab5d43cad636446630054cd4c22c
│ │ │ ├── b
│ │ │ │ ├── 5bcf64a2307c337a1623b09ddea03e466155f5b0
│ │ │ │ └── 5bf1396bc1ef85c4a70bf906e2589b4fc0eea76a
│ │ │ └── e
│ │ │ │ └── 5e14658257e45ecab45c3c1839f4baac4dd3d0fd
│ │ │ ├── 6
│ │ │ ├── 0
│ │ │ │ └── 60ae1ddb0dc740288b79add58d7e49b1f0631a1d
│ │ │ ├── a
│ │ │ │ ├── 6a4315c296ab8685b9f7a7217d5aaa64f05d41de
│ │ │ │ └── 6ab8e2873d3161829640309d3e9a3557ddda0562
│ │ │ ├── b
│ │ │ │ └── 6be9a9399ddf2d310d355039c46700afd6d814be
│ │ │ └── c
│ │ │ │ └── 6c542516ec6493a3efd0662941620ae9cda130d4
│ │ │ ├── 7
│ │ │ ├── 1
│ │ │ │ └── 71b08e84b1dc4eab321d9688586029ed04a4e45e
│ │ │ ├── 2
│ │ │ │ └── 724c31139291ad2857faf33bbda142e0a2687b58
│ │ │ ├── 3
│ │ │ │ └── 73d37a70b721c4841192b81b9b214bdc68e423a9
│ │ │ ├── 6
│ │ │ │ └── 764d42985ac7eeafb461efd914e4544eeefd2ccc
│ │ │ └── c
│ │ │ │ └── 7ce81b448ea5e7634714f30d6002aa134868f135
│ │ │ ├── 8
│ │ │ ├── 8
│ │ │ │ └── 88ed555a2ad3c115e28ade4e70b1e7550c15942d
│ │ │ ├── 9
│ │ │ │ └── 89aa268f511890bce4b0fab6fe328910a98615a7
│ │ │ ├── c
│ │ │ │ └── 8c987785ceb6540273791ace20e1c8080cdbf1ac
│ │ │ └── f
│ │ │ │ └── 8f86d62760efd398a0b5576c98b03cc4be6299ac
│ │ │ ├── 9
│ │ │ ├── 0
│ │ │ │ └── 90bfe7d78eae1f08ccfc683305c768f8820a1a46
│ │ │ ├── 4
│ │ │ │ ├── 94058fe9cb47faad8713859eb0de529f5bdd5939
│ │ │ │ └── 94f58732b2e79ae7f9f988954c86c108295925a4
│ │ │ ├── 6
│ │ │ │ └── 960fa34aff8c445d68c12aeb2afe071500d0fe05
│ │ │ ├── 7
│ │ │ │ └── 9733cb28543aebc10a7450128dd271e84242fd0c
│ │ │ └── e
│ │ │ │ └── 9ea48ee8998c212657b867030ca90d6af0aadbe0
│ │ │ ├── a
│ │ │ ├── 1
│ │ │ │ ├── a1be5dab2492f1d5b1ff4bd1d68f5c8deb0c19b0
│ │ │ │ └── a1faedf9ef4d329a8780c91fb02aeb2953cbea65
│ │ │ ├── 2
│ │ │ │ └── a231be4c72d71cc521d928cfe64650abc95cb220
│ │ │ ├── 6
│ │ │ │ └── a62d1041500efd12fb59310839353c85413c89e3
│ │ │ ├── 7
│ │ │ │ ├── a701ff305a8448a710ae9f56b0e30109497faa41
│ │ │ │ └── a77200681596370700774b9443ebae690a0a6990
│ │ │ └── c
│ │ │ │ └── ac8bf60e1a26f69b8d80ee78561f910adedb4977
│ │ │ ├── b
│ │ │ ├── 0
│ │ │ │ └── b0fc8ea2125f12d29fccc6fe2c208f76f71ecd24
│ │ │ ├── 3
│ │ │ │ └── b31f9ce5cac25405db7bcfb4236f1bf01130d68a
│ │ │ ├── 7
│ │ │ │ └── b7b91d1e37d82a99a88f9cf338154607a7872787
│ │ │ ├── a
│ │ │ │ ├── ba8273f0c078f4926424e8683bc99e9460db07f5
│ │ │ │ └── baf87c470b71a63655b068807700177115672db5
│ │ │ └── f
│ │ │ │ └── bffca00c78b9698c3995947a3faf51d994bd2cc5
│ │ │ ├── c
│ │ │ ├── 3
│ │ │ │ ├── c39a0d9cb3a11eed584fe17b3077e5cf898af5ea
│ │ │ │ └── c3e9267469c7d0b4c6bf2473c9b921bc41622d48
│ │ │ └── d
│ │ │ │ └── cd13b73b1ff25e513bf56af8d2c36881e66e4b1e
│ │ │ ├── d
│ │ │ ├── 1
│ │ │ │ └── d1b08a34e5c898671222433fe299b0beb5c46bef
│ │ │ ├── 2
│ │ │ │ └── d2a9438667e382953dc249fa83af37491a990c3c
│ │ │ ├── 3
│ │ │ │ └── d3bf5b2196b13bd511ebea8705fc5b98e1951073
│ │ │ ├── 7
│ │ │ │ └── d7440217984839d9720ff6d623878efc2f4d255b
│ │ │ ├── b
│ │ │ │ └── db63e6f75c00469d6421eb9ee3cec29f01c64ea6
│ │ │ └── e
│ │ │ │ ├── de789e2947eeff6fd133161720807e6be972d09b
│ │ │ │ └── defacc1c71bc58078de279283b74af03a3d5358e
│ │ │ ├── e
│ │ │ ├── 0
│ │ │ │ └── e0840505e5b8afd2e90805d2fab2b3699f74934b
│ │ │ ├── 4
│ │ │ │ └── e47b96fcb1e671c1f7bba392bb9faa1a7f1f8d8c
│ │ │ ├── 7
│ │ │ │ └── e7d089f97544d6218ac315c2aadcecec0fd536b1
│ │ │ ├── 8
│ │ │ │ └── e85dc525acab50ca7c2fe75d0fa7d171f31d46a3
│ │ │ ├── c
│ │ │ │ └── ec2631df5bc77477b75548b0a6a2d3d3d73d94ae
│ │ │ └── f
│ │ │ │ └── efbdbf6aa65ba0460ca542aa72d7668a330054e0
│ │ │ ├── f
│ │ │ ├── 3
│ │ │ │ ├── f3548356a6e38a263d16519c38c083e6195aa56c
│ │ │ │ └── f3bd6c35019906fc7d78361ca7c90a12945ce6ec
│ │ │ ├── 5
│ │ │ │ └── f551e0b98f2450017a75d57afeb6132bf726a1c5
│ │ │ ├── 6
│ │ │ │ └── f606ea802a8728b59604e46e34dade91ea6bfde4
│ │ │ ├── 9
│ │ │ │ └── f94f541ddc062375866943fa83c7ef9d2d232ade
│ │ │ └── c
│ │ │ │ ├── fc8fe0d18415edfad076a3e5cbe2bf0b6a4e8890
│ │ │ │ └── fcce616184b45d3fdd67051308436197b48b2bb0
│ │ │ └── index.pb
│ ├── uiDesigner.xml
│ └── workspace.xml
├── OOP-SOLID.iml
├── pom.xml
└── src
│ └── dev
│ └── patika
│ └── spring
│ ├── Main.java
│ ├── abstraction
│ ├── abstracts
│ │ ├── DailyDiscount.java
│ │ ├── Discount.java
│ │ ├── Main.java
│ │ └── SuperDiscount.java
│ └── interfaces
│ │ ├── DailyDiscount.java
│ │ ├── Discount.java
│ │ ├── Main.java
│ │ └── SuperDiscount.java
│ ├── clzzobjects
│ ├── Main.java
│ ├── Order.java
│ └── OrderItem.java
│ ├── designpatternsofday
│ └── singleton
│ │ ├── LazyInitializationNonThreadSafeSingleton.java
│ │ ├── LazyInitializationThreadSafeSingleton.java
│ │ ├── Main.java
│ │ ├── NonLazyInitializationThreadSafeSingleton.java
│ │ └── SingletonRunnable.java
│ ├── encapsulation
│ ├── Engine.java
│ └── Main.java
│ ├── inheritance
│ ├── hiyerarchical
│ │ ├── Main.java
│ │ ├── Player.java
│ │ └── Teacher.java
│ ├── multilevel
│ │ ├── EngineeringStudent.java
│ │ └── Main.java
│ └── single
│ │ ├── Human.java
│ │ ├── Main.java
│ │ └── Student.java
│ ├── order
│ ├── CreateOrderService.java
│ ├── CreateOrderServiceImpl.java
│ ├── CustomerBalanceChecker.java
│ ├── DefaultCustomerBalanceCheckerImpl.java
│ ├── NoCustomerBalanceChecker.java
│ └── ZeroCustomerBalanceCheckerImpl.java
│ ├── polyphormism
│ ├── Calculator.java
│ └── Main.java
│ └── solid
│ ├── dip
│ ├── bad
│ │ ├── Caller.java
│ │ ├── Email.java
│ │ ├── Letter.java
│ │ ├── Notification.java
│ │ └── SMS.java
│ └── good
│ │ ├── Caller.java
│ │ ├── Email.java
│ │ ├── Letter.java
│ │ ├── Message.java
│ │ ├── Notification.java
│ │ └── SMS.java
│ ├── isp
│ ├── bad
│ │ ├── Button.java
│ │ ├── OnClickListener.java
│ │ └── TextBox.java
│ └── good
│ │ ├── Button.java
│ │ ├── Listener.java
│ │ ├── OnClickListener.java
│ │ ├── OnLongClickListener.java
│ │ ├── OnShortClickListener.java
│ │ └── Text.java
│ ├── lsp
│ ├── bad
│ │ ├── Bird.java
│ │ ├── Duck.java
│ │ └── Ostrich.java
│ ├── good
│ │ ├── Bird.java
│ │ ├── Duck.java
│ │ ├── Flyable.java
│ │ ├── Ostrich.java
│ │ └── Walk.java
│ └── lnew
│ │ ├── Human.java
│ │ ├── HumanInPandemicTimes.java
│ │ ├── HumanInWarTimes.java
│ │ ├── HumanNotInPandemicTimes.java
│ │ └── Student.java
│ ├── ocp
│ ├── bad
│ │ ├── Addition.java
│ │ ├── Calculator.java
│ │ ├── CalculatorOperation.java
│ │ ├── Division.java
│ │ ├── Main.java
│ │ └── Subtraction.java
│ └── good
│ │ ├── Addition.java
│ │ ├── Calculator.java
│ │ ├── CalculatorOperation.java
│ │ ├── Division.java
│ │ ├── Main.java
│ │ └── Subtraction.java
│ └── srp
│ ├── bad
│ └── BadSRPApproach.java
│ └── good
│ ├── DataWriter.java
│ ├── DatabaseConnection.java
│ └── QueryExecutor.java
├── README.md
├── Spring Java Egitimi.pptx
├── SpringBootNorma.pptx
├── jpa-examples
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── patikadev
│ │ │ └── jpaexamples
│ │ │ ├── JpaExamplesApplication.java
│ │ │ └── entity
│ │ │ ├── BaseEntity.java
│ │ │ ├── BaseExtendedEntity.java
│ │ │ ├── Course.java
│ │ │ ├── DepartmentEnum.java
│ │ │ ├── Student.java
│ │ │ └── StudentAddress.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── org
│ └── patikadev
│ └── jpaexamples
│ └── JpaExamplesApplicationTests.java
├── order-example
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── patikadev
│ │ │ └── orderexample
│ │ │ ├── OrderExampleApplication.java
│ │ │ ├── controller
│ │ │ ├── BaseControllerAdvice.java
│ │ │ └── CustomerController.java
│ │ │ ├── converter
│ │ │ ├── CustomerConverter.java
│ │ │ └── CustomerConverterImpl.java
│ │ │ ├── dto
│ │ │ ├── CreateCustomerRequestDTO.java
│ │ │ ├── CustomerAddressDTO.java
│ │ │ └── GetCustomersResponseDTO.java
│ │ │ ├── exception
│ │ │ ├── BaseException.java
│ │ │ ├── BaseValidationException.java
│ │ │ ├── BusinessServiceOperationException.java
│ │ │ └── ValidationOperationException.java
│ │ │ ├── model
│ │ │ ├── BaseExtendedModel.java
│ │ │ ├── BaseModel.java
│ │ │ ├── Basket.java
│ │ │ ├── BasketItem.java
│ │ │ ├── Brand.java
│ │ │ ├── Category.java
│ │ │ ├── Customer.java
│ │ │ ├── CustomerAddress.java
│ │ │ ├── Gender.java
│ │ │ └── Product.java
│ │ │ ├── repository
│ │ │ └── CustomerRepository.java
│ │ │ ├── service
│ │ │ ├── CustomerService.java
│ │ │ └── CustomerServiceImpl.java
│ │ │ └── validator
│ │ │ ├── CreateCustomerRequestValidator.java
│ │ │ ├── CustomerIDValidator.java
│ │ │ └── Validator.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── org
│ └── patikadev
│ └── orderexample
│ └── OrderExampleApplicationTests.java
├── proxy-design-pattern
├── .idea
│ ├── .gitignore
│ ├── description.html
│ ├── encodings.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── project-template.xml
│ ├── runConfigurations.xml
│ ├── sonarlint
│ │ └── issuestore
│ │ │ ├── 0
│ │ │ └── 7
│ │ │ │ └── 0718adcc89accfcfba0ef98c4c79cd538c12e17a
│ │ │ ├── 3
│ │ │ └── 5
│ │ │ │ └── 357f0a3c0a04084e4cd5a471d68ecf6835c061e7
│ │ │ ├── e
│ │ │ └── 8
│ │ │ │ └── e8b71cf26b4779249765a837676a7075ce95d804
│ │ │ ├── f
│ │ │ └── 9
│ │ │ │ └── f94f541ddc062375866943fa83c7ef9d2d232ade
│ │ │ └── index.pb
│ ├── uiDesigner.xml
│ └── vcs.xml
├── proxy-design-pattern.iml
└── src
│ └── dev
│ └── patika
│ └── spring
│ ├── Main.java
│ ├── President.java
│ ├── ProxyPresident.java
│ └── RealPresident.java
├── rest-service
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── dev
│ │ │ └── patika
│ │ │ └── restservice
│ │ │ ├── RestServiceApplication.java
│ │ │ ├── controller
│ │ │ ├── RestServiceControllerAdvice.java
│ │ │ └── WarehouseController.java
│ │ │ ├── exceptions
│ │ │ ├── PatikaDevBootcampControllerException.java
│ │ │ └── RequestParameterNotValidException.java
│ │ │ └── model
│ │ │ └── WarehouseModel.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── dev
│ └── patika
│ └── restservice
│ └── RestServiceApplicationTests.java
├── sp-core
├── .idea
│ ├── .gitignore
│ ├── compiler.xml
│ ├── jarRepositories.xml
│ ├── misc.xml
│ ├── runConfigurations.xml
│ └── sonarlint
│ │ └── issuestore
│ │ ├── 0
│ │ ├── 2
│ │ │ └── 025c6d3ce74ff3a34ed2eb402dda4de27250535d
│ │ └── d
│ │ │ └── 0d1c5e2749d82b75b31ee3add09b12949e82639a
│ │ ├── 2
│ │ ├── a
│ │ │ └── 2a7e6c061e93f42dace537cb3432475c46646428
│ │ └── e
│ │ │ └── 2e82b65470137429f7a74217a23b82d4a9bfe968
│ │ ├── 4
│ │ └── 4
│ │ │ └── 442292b8a7efeabbe4cc176709b833b1792140ec
│ │ ├── 5
│ │ └── 0
│ │ │ └── 50e22bb237393735bb14b2f347782d84243de526
│ │ ├── 6
│ │ └── d
│ │ │ └── 6d1037c8686b1235851a981a79297dcaf0bb0917
│ │ ├── 7
│ │ └── 2
│ │ │ └── 72bfd8c707c7f2452e49dd10a9f972bc1ad0c08c
│ │ ├── 9
│ │ └── f
│ │ │ └── 9fca2448ea657635e4fa1971e51353c45b49a64d
│ │ ├── d
│ │ ├── 6
│ │ │ └── d6eef06968b700406a75043942e73224cb41fe6f
│ │ ├── 8
│ │ │ └── d8a7d6a75f2bb10f06cfbee5ab6644d47226f91a
│ │ └── b
│ │ │ └── db9f26078aa1bfe68bed16f23e7b4ad516668ed6
│ │ ├── f
│ │ └── 5
│ │ │ └── f5ea8f01e9f11e11872ac10af80f68508519e299
│ │ └── index.pb
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── dev
│ │ └── patika
│ │ └── spring
│ │ ├── PatikaDevApplication.java
│ │ ├── config
│ │ └── ApplicationConfiguration.java
│ │ ├── controller
│ │ └── OrderController.java
│ │ ├── model
│ │ ├── Order.java
│ │ ├── OrderItem.java
│ │ └── Product.java
│ │ └── service
│ │ ├── CustomerService.java
│ │ ├── CustomerServiceImpl.java
│ │ ├── OrderService.java
│ │ ├── OrderServiceImpl.java
│ │ ├── ProductService.java
│ │ └── ProductServiceImpl.java
│ └── resources
│ ├── configuration-2.xml
│ └── configuration.xml
├── spring-boot
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── dev
│ │ │ └── patika
│ │ │ └── springboot
│ │ │ ├── Application.java
│ │ │ ├── BusinessService.java
│ │ │ ├── CustomComponent.java
│ │ │ ├── CustomComponentImpl.java
│ │ │ ├── CustomController.java
│ │ │ ├── CustomRepository.java
│ │ │ ├── CustomRepositoryImpl.java
│ │ │ ├── CustomService.java
│ │ │ ├── CustomServiceImpl.java
│ │ │ └── MyConfiguration.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── dev
│ └── patika
│ └── springboot
│ └── ApplicationTests.java
├── spring-security-jwt-api
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── patikadev
│ │ │ └── springsecurityjwtapi
│ │ │ ├── SpringSecurityJwtApiApplication.java
│ │ │ ├── config
│ │ │ ├── InitializerConfig.java
│ │ │ └── SecurityConfig.java
│ │ │ ├── controller
│ │ │ ├── AuthenticationController.java
│ │ │ └── CustomerController.java
│ │ │ ├── entity
│ │ │ ├── Customer.java
│ │ │ ├── Role.java
│ │ │ ├── User.java
│ │ │ └── enums
│ │ │ │ └── UserStatus.java
│ │ │ ├── filter
│ │ │ └── JWTAuthenticationFilter.java
│ │ │ ├── helper
│ │ │ ├── DataCreator.java
│ │ │ └── JWTHelper.java
│ │ │ ├── model
│ │ │ ├── AuthenticationRequest.java
│ │ │ └── AuthenticationResponse.java
│ │ │ ├── repository
│ │ │ ├── CustomerRepository.java
│ │ │ └── UserRepository.java
│ │ │ ├── security
│ │ │ ├── JWTAuthenticationEntryPoint.java
│ │ │ ├── UserDetail.java
│ │ │ └── UserDetailService.java
│ │ │ └── validator
│ │ │ └── AuthenticationRequestValidator.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── org
│ └── patikadev
│ └── springsecurityjwtapi
│ ├── BcryptPasswordEncoderTest.java
│ └── UserTests.java
└── spring-security
└── src
└── main
└── java
└── org
└── patikadev
└── springsecurity
├── configuration
├── CustomConfiguration.java
└── SecurityConfiguration.java
├── entities
└── MyUser.java
├── repository
├── LoggedUser.java
└── UserRepository.java
├── security
└── H2DatabaseUserDetailService.java
└── service
└── UserService.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 |
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/.gitignore
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/0/0/0027c168f7e900e7ed7f3e48e4080f85b1e6fffa:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/0/0/0027c168f7e900e7ed7f3e48e4080f85b1e6fffa
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/0/6/06205613f9bed6cb87024c9ab3fc22a1f574d1d7:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/0/6/06205613f9bed6cb87024c9ab3fc22a1f574d1d7
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/0/6/062bb33dd249ddd09565cf350099ba65827ae161:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/0/6/062bb33dd249ddd09565cf350099ba65827ae161
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/0/b/0bfa9855144eeb26e50e5f86000263c17ac65fd8:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/0/b/0bfa9855144eeb26e50e5f86000263c17ac65fd8
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/1/0/1005d45cec92b04aae10302b0e30b1b7bb6e172c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/1/0/1005d45cec92b04aae10302b0e30b1b7bb6e172c
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/1/3/132b235240c4e5475a36b9c6d5be7119e0ae0dbb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/1/3/132b235240c4e5475a36b9c6d5be7119e0ae0dbb
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/1/6/169c302b28e8c71f1747845698ae30a1e0b956a5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/1/6/169c302b28e8c71f1747845698ae30a1e0b956a5
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/1/9/19a329d20b9bad9656ee7b1712ddf28c1df0adbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/1/9/19a329d20b9bad9656ee7b1712ddf28c1df0adbf
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/1/e/1eff4bb119bd9cd888b0975b06d8c6a62e68f893:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/1/e/1eff4bb119bd9cd888b0975b06d8c6a62e68f893
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/2/0/205e59c9f3da8d1262760dcaf3a0c4daee5098d5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/2/0/205e59c9f3da8d1262760dcaf3a0c4daee5098d5
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/2/1/217fc70d99b8bb8cabf6b542a91e2172132f06c1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/2/1/217fc70d99b8bb8cabf6b542a91e2172132f06c1
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/2/4/24f35fd1817c2613169eec96a357d7c3983ee6a8:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/2/4/24f35fd1817c2613169eec96a357d7c3983ee6a8
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/2/6/2622e5c76da42dcaea6f9bbd9d39b875677381d7:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/2/6/2622e5c76da42dcaea6f9bbd9d39b875677381d7
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/2/7/273720983f5f04ac2a907602142dc4da4fda1fd1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/2/7/273720983f5f04ac2a907602142dc4da4fda1fd1
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/2/8/284b590176f0c342282a48b0e208aefd7026169d:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/2/8/284b590176f0c342282a48b0e208aefd7026169d
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/2/9/2956a1247823b52c76b503eb1beccd6c4daee3fb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/2/9/2956a1247823b52c76b503eb1beccd6c4daee3fb
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/2/b/2bdd6f3ec77f7eccf104c87f23a657b01de8e3ed:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/2/b/2bdd6f3ec77f7eccf104c87f23a657b01de8e3ed
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/3/5/35fa1e39a2d68dbeb4c3ee041c1ef87e04fda7f2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/3/5/35fa1e39a2d68dbeb4c3ee041c1ef87e04fda7f2
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/3/b/3b4482329013953eca7bb226a6807ebe4fa9f609:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/3/b/3b4482329013953eca7bb226a6807ebe4fa9f609
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/3/d/3dbfd2d614e5109b2fd39362f3ae69006a0a87f6:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/3/d/3dbfd2d614e5109b2fd39362f3ae69006a0a87f6
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/4/3/43a0d03ebf4aba57a6e52d3223178444953e882b:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/4/3/43a0d03ebf4aba57a6e52d3223178444953e882b
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/4/4/442292b8a7efeabbe4cc176709b833b1792140ec:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/4/4/442292b8a7efeabbe4cc176709b833b1792140ec
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/4/c/4c220f465d49e57892b9db8eab1958ccd637a049:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/4/c/4c220f465d49e57892b9db8eab1958ccd637a049
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/4/e/4edeca64a2c69a3e6dce7685201bc494f33b7009:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/4/e/4edeca64a2c69a3e6dce7685201bc494f33b7009
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/5/8/58ab0fbaf9eeab5d43cad636446630054cd4c22c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/5/8/58ab0fbaf9eeab5d43cad636446630054cd4c22c
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/5/b/5bcf64a2307c337a1623b09ddea03e466155f5b0:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/5/b/5bcf64a2307c337a1623b09ddea03e466155f5b0
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/5/b/5bf1396bc1ef85c4a70bf906e2589b4fc0eea76a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/5/b/5bf1396bc1ef85c4a70bf906e2589b4fc0eea76a
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/5/e/5e14658257e45ecab45c3c1839f4baac4dd3d0fd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/5/e/5e14658257e45ecab45c3c1839f4baac4dd3d0fd
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/6/0/60ae1ddb0dc740288b79add58d7e49b1f0631a1d:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/6/0/60ae1ddb0dc740288b79add58d7e49b1f0631a1d
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/6/a/6a4315c296ab8685b9f7a7217d5aaa64f05d41de:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/6/a/6a4315c296ab8685b9f7a7217d5aaa64f05d41de
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/6/a/6ab8e2873d3161829640309d3e9a3557ddda0562:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/6/a/6ab8e2873d3161829640309d3e9a3557ddda0562
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/6/b/6be9a9399ddf2d310d355039c46700afd6d814be:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/6/b/6be9a9399ddf2d310d355039c46700afd6d814be
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/6/c/6c542516ec6493a3efd0662941620ae9cda130d4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/6/c/6c542516ec6493a3efd0662941620ae9cda130d4
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/7/1/71b08e84b1dc4eab321d9688586029ed04a4e45e:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/7/1/71b08e84b1dc4eab321d9688586029ed04a4e45e
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/7/2/724c31139291ad2857faf33bbda142e0a2687b58:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/7/2/724c31139291ad2857faf33bbda142e0a2687b58
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/7/3/73d37a70b721c4841192b81b9b214bdc68e423a9:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/7/3/73d37a70b721c4841192b81b9b214bdc68e423a9
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/7/6/764d42985ac7eeafb461efd914e4544eeefd2ccc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/7/6/764d42985ac7eeafb461efd914e4544eeefd2ccc
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/7/c/7ce81b448ea5e7634714f30d6002aa134868f135:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/7/c/7ce81b448ea5e7634714f30d6002aa134868f135
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/8/8/88ed555a2ad3c115e28ade4e70b1e7550c15942d:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/8/8/88ed555a2ad3c115e28ade4e70b1e7550c15942d
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/8/9/89aa268f511890bce4b0fab6fe328910a98615a7:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/8/9/89aa268f511890bce4b0fab6fe328910a98615a7
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/8/c/8c987785ceb6540273791ace20e1c8080cdbf1ac:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/8/c/8c987785ceb6540273791ace20e1c8080cdbf1ac
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/8/f/8f86d62760efd398a0b5576c98b03cc4be6299ac:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/8/f/8f86d62760efd398a0b5576c98b03cc4be6299ac
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/9/0/90bfe7d78eae1f08ccfc683305c768f8820a1a46:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/9/0/90bfe7d78eae1f08ccfc683305c768f8820a1a46
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/9/4/94058fe9cb47faad8713859eb0de529f5bdd5939:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/9/4/94058fe9cb47faad8713859eb0de529f5bdd5939
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/9/4/94f58732b2e79ae7f9f988954c86c108295925a4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/9/4/94f58732b2e79ae7f9f988954c86c108295925a4
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/9/6/960fa34aff8c445d68c12aeb2afe071500d0fe05:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/9/6/960fa34aff8c445d68c12aeb2afe071500d0fe05
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/9/7/9733cb28543aebc10a7450128dd271e84242fd0c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/9/7/9733cb28543aebc10a7450128dd271e84242fd0c
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/9/e/9ea48ee8998c212657b867030ca90d6af0aadbe0:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/9/e/9ea48ee8998c212657b867030ca90d6af0aadbe0
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/a/1/a1be5dab2492f1d5b1ff4bd1d68f5c8deb0c19b0:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/a/1/a1be5dab2492f1d5b1ff4bd1d68f5c8deb0c19b0
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/a/1/a1faedf9ef4d329a8780c91fb02aeb2953cbea65:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/a/1/a1faedf9ef4d329a8780c91fb02aeb2953cbea65
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/a/2/a231be4c72d71cc521d928cfe64650abc95cb220:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/a/2/a231be4c72d71cc521d928cfe64650abc95cb220
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/a/6/a62d1041500efd12fb59310839353c85413c89e3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/a/6/a62d1041500efd12fb59310839353c85413c89e3
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/a/7/a701ff305a8448a710ae9f56b0e30109497faa41:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/a/7/a701ff305a8448a710ae9f56b0e30109497faa41
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/a/7/a77200681596370700774b9443ebae690a0a6990:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/a/7/a77200681596370700774b9443ebae690a0a6990
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/a/c/ac8bf60e1a26f69b8d80ee78561f910adedb4977:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/a/c/ac8bf60e1a26f69b8d80ee78561f910adedb4977
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/b/0/b0fc8ea2125f12d29fccc6fe2c208f76f71ecd24:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/b/0/b0fc8ea2125f12d29fccc6fe2c208f76f71ecd24
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/b/3/b31f9ce5cac25405db7bcfb4236f1bf01130d68a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/b/3/b31f9ce5cac25405db7bcfb4236f1bf01130d68a
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/b/7/b7b91d1e37d82a99a88f9cf338154607a7872787:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/b/7/b7b91d1e37d82a99a88f9cf338154607a7872787
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/b/a/ba8273f0c078f4926424e8683bc99e9460db07f5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/b/a/ba8273f0c078f4926424e8683bc99e9460db07f5
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/b/a/baf87c470b71a63655b068807700177115672db5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/b/a/baf87c470b71a63655b068807700177115672db5
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/b/f/bffca00c78b9698c3995947a3faf51d994bd2cc5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/b/f/bffca00c78b9698c3995947a3faf51d994bd2cc5
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/c/3/c39a0d9cb3a11eed584fe17b3077e5cf898af5ea:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/c/3/c39a0d9cb3a11eed584fe17b3077e5cf898af5ea
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/c/3/c3e9267469c7d0b4c6bf2473c9b921bc41622d48:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/c/3/c3e9267469c7d0b4c6bf2473c9b921bc41622d48
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/c/d/cd13b73b1ff25e513bf56af8d2c36881e66e4b1e:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/c/d/cd13b73b1ff25e513bf56af8d2c36881e66e4b1e
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/d/1/d1b08a34e5c898671222433fe299b0beb5c46bef:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/d/1/d1b08a34e5c898671222433fe299b0beb5c46bef
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/d/2/d2a9438667e382953dc249fa83af37491a990c3c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/d/2/d2a9438667e382953dc249fa83af37491a990c3c
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/d/3/d3bf5b2196b13bd511ebea8705fc5b98e1951073:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/d/3/d3bf5b2196b13bd511ebea8705fc5b98e1951073
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/d/7/d7440217984839d9720ff6d623878efc2f4d255b:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/d/7/d7440217984839d9720ff6d623878efc2f4d255b
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/d/b/db63e6f75c00469d6421eb9ee3cec29f01c64ea6:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/d/b/db63e6f75c00469d6421eb9ee3cec29f01c64ea6
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/d/e/de789e2947eeff6fd133161720807e6be972d09b:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/d/e/de789e2947eeff6fd133161720807e6be972d09b
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/d/e/defacc1c71bc58078de279283b74af03a3d5358e:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/d/e/defacc1c71bc58078de279283b74af03a3d5358e
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/e/0/e0840505e5b8afd2e90805d2fab2b3699f74934b:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/e/0/e0840505e5b8afd2e90805d2fab2b3699f74934b
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/e/4/e47b96fcb1e671c1f7bba392bb9faa1a7f1f8d8c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/e/4/e47b96fcb1e671c1f7bba392bb9faa1a7f1f8d8c
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/e/7/e7d089f97544d6218ac315c2aadcecec0fd536b1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/e/7/e7d089f97544d6218ac315c2aadcecec0fd536b1
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/e/8/e85dc525acab50ca7c2fe75d0fa7d171f31d46a3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/e/8/e85dc525acab50ca7c2fe75d0fa7d171f31d46a3
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/e/c/ec2631df5bc77477b75548b0a6a2d3d3d73d94ae:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/e/c/ec2631df5bc77477b75548b0a6a2d3d3d73d94ae
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/e/f/efbdbf6aa65ba0460ca542aa72d7668a330054e0:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/e/f/efbdbf6aa65ba0460ca542aa72d7668a330054e0
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/f/3/f3548356a6e38a263d16519c38c083e6195aa56c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/f/3/f3548356a6e38a263d16519c38c083e6195aa56c
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/f/3/f3bd6c35019906fc7d78361ca7c90a12945ce6ec:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/f/3/f3bd6c35019906fc7d78361ca7c90a12945ce6ec
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/f/5/f551e0b98f2450017a75d57afeb6132bf726a1c5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/f/5/f551e0b98f2450017a75d57afeb6132bf726a1c5
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/f/6/f606ea802a8728b59604e46e34dade91ea6bfde4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/f/6/f606ea802a8728b59604e46e34dade91ea6bfde4
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/f/9/f94f541ddc062375866943fa83c7ef9d2d232ade:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/f/9/f94f541ddc062375866943fa83c7ef9d2d232ade
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/f/c/fc8fe0d18415edfad076a3e5cbe2bf0b6a4e8890:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/f/c/fc8fe0d18415edfad076a3e5cbe2bf0b6a4e8890
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/f/c/fcce616184b45d3fdd67051308436197b48b2bb0:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/f/c/fcce616184b45d3fdd67051308436197b48b2bb0
--------------------------------------------------------------------------------
/OOP-SOLID/.idea/sonarlint/issuestore/index.pb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/OOP-SOLID/.idea/sonarlint/issuestore/index.pb
--------------------------------------------------------------------------------
/OOP-SOLID/OOP-SOLID.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/OOP-SOLID/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | dev.patika
8 | OOP
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 17
13 | 17
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/Main.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring;
2 |
3 | public class Main {
4 |
5 | public static void main(String[] args) {
6 | // write your code here
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/abstraction/abstracts/DailyDiscount.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.abstraction.abstracts;
2 |
3 | import java.math.BigDecimal;
4 | import java.math.RoundingMode;
5 |
6 | /**
7 | * Username = baranbuyuk
8 | * Date = 29.07.2021 23:08
9 | **/
10 | public class DailyDiscount extends Discount {
11 |
12 | public static final BigDecimal RATE = new BigDecimal(15);
13 |
14 | public DailyDiscount(BigDecimal amount) {
15 | super(amount);
16 | }
17 |
18 | //there is better solution for this abstraction..
19 | @Override
20 | protected BigDecimal calculate() {
21 | return getAmount().subtract(getAmount()
22 | .multiply(RATE)
23 | .divide(new BigDecimal(100), RoundingMode.FLOOR));
24 | }
25 |
26 | @Override
27 | protected void nonAbstractCalculate() {
28 | System.out.println("It's implementation of DailyDiscount class.");
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/abstraction/abstracts/Discount.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.abstraction.abstracts;
2 |
3 | import java.math.BigDecimal;
4 |
5 | /**
6 | * Username = baranbuyuk
7 | * Date = 29.07.2021 23:06
8 | **/
9 | public abstract class Discount {
10 |
11 | protected abstract BigDecimal calculate();
12 |
13 | protected void nonAbstractCalculate() {
14 | System.out.println(" There is no implementation of this method");
15 | }
16 |
17 | private final BigDecimal amount;
18 |
19 |
20 | protected Discount(BigDecimal amount) {
21 | this.amount = amount;
22 | }
23 |
24 | protected BigDecimal getAmount() {
25 | return amount;
26 | }
27 |
28 | public Long getDiscountDay() {
29 | return 9L;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/abstraction/abstracts/Main.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.abstraction.abstracts;
2 |
3 | import java.math.BigDecimal;
4 |
5 | /**
6 | * Username = baranbuyuk
7 | * Date = 29.07.2021 23:15
8 | **/
9 |
10 | /**
11 | * Below topics should be mention
12 | * 1-What is abstract method and non-abstract methods in the abstract classes
13 | * 2-What is final methods in abstract classes?
14 | */
15 | public class Main {
16 |
17 | public static void main(String[] args) {
18 |
19 | Discount dailyDiscount = new DailyDiscount(new BigDecimal(100));
20 | System.out.println(dailyDiscount.calculate());
21 | dailyDiscount.nonAbstractCalculate();
22 |
23 | Discount superDiscount = new SuperDiscount(new BigDecimal(100));
24 | System.out.println(superDiscount.calculate());
25 | superDiscount.nonAbstractCalculate();
26 |
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/abstraction/abstracts/SuperDiscount.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.abstraction.abstracts;
2 |
3 | import java.math.BigDecimal;
4 | import java.math.RoundingMode;
5 |
6 | /**
7 | * Username = baranbuyuk
8 | * Date = 29.07.2021 23:13
9 | **/
10 | public class SuperDiscount extends Discount {
11 |
12 | private static final BigDecimal RATE = new BigDecimal(80);
13 |
14 | protected SuperDiscount(BigDecimal amount) {
15 | super(amount);
16 | }
17 |
18 | //there is better solution for this abstraction..
19 | @Override
20 | protected BigDecimal calculate() {
21 | return getAmount().subtract(getAmount()
22 | .multiply(RATE)
23 | .divide(new BigDecimal(100), RoundingMode.FLOOR));
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/abstraction/interfaces/DailyDiscount.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.abstraction.interfaces;
2 |
3 | import java.math.BigDecimal;
4 | import java.math.RoundingMode;
5 |
6 | /**
7 | * Username = baranbuyuk
8 | * Date = 30.07.2021 00:12
9 | **/
10 | public class DailyDiscount implements Discount {
11 |
12 | public static final BigDecimal RATE = new BigDecimal(15);
13 |
14 | private final BigDecimal amount;
15 |
16 | public DailyDiscount(BigDecimal amount) {
17 | this.amount = amount;
18 | }
19 |
20 | public DailyDiscount(double amount) {
21 | this.amount = BigDecimal.valueOf(amount);
22 | }
23 |
24 | @Override
25 | public BigDecimal calculate() {
26 | return amount.subtract(amount
27 | .multiply(RATE)
28 | .divide(new BigDecimal(100), RoundingMode.FLOOR));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/abstraction/interfaces/Discount.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.abstraction.interfaces;
2 |
3 | import java.math.BigDecimal;
4 |
5 | /**
6 | * Username = baranbuyuk
7 | * Date = 30.07.2021 00:11
8 | **/
9 | public interface Discount {
10 |
11 | BigDecimal calculate();
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/abstraction/interfaces/Main.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.abstraction.interfaces;
2 |
3 | import java.math.BigDecimal;
4 |
5 |
6 | /**
7 | * 1- What is interface? What is purpose of Interface and where should we use it?
8 | * 2- What are differences between abstract classes and interfaces
9 | * 3-W hat is default method in the interfaces? Where should we use it?
10 | */
11 | public class Main {
12 |
13 | public static void main(String[] args) {
14 | Discount dailyDiscount = new DailyDiscount(BigDecimal.valueOf(100));
15 | System.out.println(dailyDiscount.calculate());
16 |
17 | Discount superDiscount = new SuperDiscount(100);
18 | System.out.println(superDiscount.calculate());
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/abstraction/interfaces/SuperDiscount.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.abstraction.interfaces;
2 |
3 | import java.math.BigDecimal;
4 | import java.math.RoundingMode;
5 |
6 | /**
7 | * Username = baranbuyuk
8 | * Date = 30.07.2021 00:12
9 | **/
10 | public class SuperDiscount implements Discount {
11 |
12 | private static final BigDecimal RATE = new BigDecimal(80);
13 |
14 | private final BigDecimal amount;
15 |
16 | public SuperDiscount(BigDecimal amount) {
17 | this.amount = amount;
18 | }
19 |
20 | public SuperDiscount(double amount) {
21 | this.amount = BigDecimal.valueOf(amount);
22 | }
23 |
24 | @Override
25 | public BigDecimal calculate() {
26 | return amount.subtract(amount
27 | .multiply(RATE)
28 | .divide(new BigDecimal(100), RoundingMode.FLOOR));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/clzzobjects/Main.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.clzzobjects;
2 |
3 | /**
4 | * Username = baranbuyuk
5 | * Date = 29.07.2021 21:26
6 | **/
7 |
8 | import java.math.BigDecimal;
9 | import java.util.Collections;
10 | import java.util.List;
11 |
12 | /**
13 | * below topics should be mention.
14 | * 1- How to create an instance from a class
15 | * 2- How to access to field in a class via instance.
16 | * 3- What is constructor, what is the purpose of it? What is with arg parameters constructor?
17 | * 4- What is private constructor?
18 | */
19 | public class Main{
20 |
21 | // if the listeners want to know what is main method and how it works, mention about it.
22 | public static void main(String[] args) {
23 |
24 |
25 | //Create new instance from Order.
26 | // when we create an new instance from order, we've called a no-args constructor of this class.
27 | Order orderInstanceWithNoArgsConstructor = new Order(); // this parentheses show us that no-args parameter we've called
28 | // now we have an instance from Order class.. JVM allocate this instance in the Heap area.
29 |
30 |
31 | // now we can access to some fields on the class which is marked as public or protected
32 | BigDecimal amount = orderInstanceWithNoArgsConstructor.amount; // we should expect that amount is null;
33 | List orderItems = orderInstanceWithNoArgsConstructor.items; // we should expect that orderItems is null;
34 | // we can not access the field which is marked as private modifier access.
35 |
36 | System.out.println(amount == null);
37 | System.out.println(orderItems == null);
38 |
39 |
40 | Order orderInstanceWithArgConstructor = new Order(Collections.emptyList(), new BigDecimal(100), new BigDecimal(18));
41 | //now we have a new instance from Order class..
42 | //each instance different from other
43 |
44 | System.out.printf("Order Instances different is -> %s \n", orderInstanceWithArgConstructor.equals(orderInstanceWithNoArgsConstructor));
45 |
46 | BigDecimal amountWithArgs = orderInstanceWithArgConstructor.amount; // we should expect amount is 100
47 | List orderItemsWithArgs = orderInstanceWithArgConstructor.items; // we should amount is empty
48 | // we can not access the field which is marked as private modifier access.
49 |
50 | System.out.println(amountWithArgs == null);
51 | System.out.println(orderItemsWithArgs == null);
52 |
53 | // any question?
54 |
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/clzzobjects/Order.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.clzzobjects;
2 |
3 | /**
4 | * Username = baranbuyuk
5 | * Date = 29.07.2021 21:11
6 | **/
7 |
8 | import java.math.BigDecimal;
9 | import java.util.List;
10 |
11 | /**
12 | * below topics should be mention for class structure
13 | * 1- access modifiers for class, variables and methods.
14 | * 2- variables
15 | * 3- methods
16 | * 4- constructors, constructors with parameters
17 | */
18 | public class Order {
19 |
20 | /**
21 | * default protected
22 | * it can accessible from same package and in this class
23 | * should i mention about the package structure?
24 | */
25 | List items;
26 |
27 | /**
28 | * it can accessible from everywhere via instance of this class
29 | */
30 | public BigDecimal amount;
31 |
32 | /**
33 | * this field can not accessible from anywhere expect in this class
34 | */
35 | private BigDecimal vatIncludedAmount;
36 |
37 | public Order() {
38 | }
39 |
40 | public Order(List items, BigDecimal amount, BigDecimal vatIncludedAmount) {
41 | this.items = items;
42 | this.amount = amount;
43 | this.vatIncludedAmount = vatIncludedAmount;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/clzzobjects/OrderItem.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.clzzobjects;
2 |
3 | import java.math.BigDecimal;
4 |
5 | /**
6 | * Username = baranbuyuk
7 | * Date = 29.07.2021 21:16
8 | **/
9 | public class OrderItem {
10 |
11 | private String name;
12 | private String amount;
13 | private BigDecimal quantity;
14 | private int lineOrder;
15 |
16 | public OrderItem() {
17 | }
18 |
19 | public OrderItem(String name, String amount, BigDecimal quantity, int lineOrder) {
20 | this.name = name;
21 | this.amount = amount;
22 | this.quantity = quantity;
23 | this.lineOrder = lineOrder;
24 | }
25 |
26 | public String getName() {
27 | return name;
28 | }
29 |
30 | public String getAmount() {
31 | return amount;
32 | }
33 |
34 | public BigDecimal getQuantity() {
35 | return quantity;
36 | }
37 |
38 | public int getLineOrder() {
39 | return lineOrder;
40 | }
41 |
42 | public void setName(String name) {
43 | this.name = name;
44 | }
45 |
46 | public void setAmount(String amount) {
47 | this.amount = amount;
48 | }
49 |
50 | public void setQuantity(BigDecimal quantity) {
51 | this.quantity = quantity;
52 | }
53 |
54 | public void setLineOrder(int lineOrder) {
55 | this.lineOrder = lineOrder;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/designpatternsofday/singleton/LazyInitializationNonThreadSafeSingleton.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.designpatternsofday.singleton;
2 |
3 | public final class LazyInitializationNonThreadSafeSingleton {
4 |
5 | private static LazyInitializationNonThreadSafeSingleton instance = null;
6 |
7 | private LazyInitializationNonThreadSafeSingleton() {
8 | }
9 |
10 | public static LazyInitializationNonThreadSafeSingleton getInstance() {
11 | synchronized (LazyInitializationNonThreadSafeSingleton.class) {
12 | if (instance == null) { // 0,03 ms
13 | System.out.println("Im first caller");
14 | instance = new LazyInitializationNonThreadSafeSingleton();
15 | }
16 | }
17 | return instance;
18 | }
19 |
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/designpatternsofday/singleton/LazyInitializationThreadSafeSingleton.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.designpatternsofday.singleton;
2 |
3 | public final class LazyInitializationThreadSafeSingleton {
4 |
5 | private LazyInitializationThreadSafeSingleton() {
6 | }
7 |
8 |
9 | public static LazyInitializationThreadSafeSingleton getInstance() {
10 | return Holder.INSTANCE;
11 | }
12 |
13 | private static class Holder {
14 | private static final LazyInitializationThreadSafeSingleton INSTANCE = new LazyInitializationThreadSafeSingleton();
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/designpatternsofday/singleton/Main.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.designpatternsofday.singleton;
2 |
3 | public class Main {
4 |
5 | public static void main(String[] args) throws InterruptedException {
6 |
7 |
8 | new Thread(new SingletonRunnable()).start();
9 | new Thread(new SingletonRunnable()).start();
10 | new Thread(new SingletonRunnable()).start();
11 | new Thread(new SingletonRunnable()).start();
12 | new Thread(new SingletonRunnable()).start();
13 |
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/designpatternsofday/singleton/NonLazyInitializationThreadSafeSingleton.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.designpatternsofday.singleton;
2 |
3 | public final class NonLazyInitializationThreadSafeSingleton {
4 |
5 | private static NonLazyInitializationThreadSafeSingleton INSTANCE =
6 | new NonLazyInitializationThreadSafeSingleton();
7 |
8 | private NonLazyInitializationThreadSafeSingleton() {
9 | }
10 |
11 | public static NonLazyInitializationThreadSafeSingleton getInstance() {
12 | return INSTANCE;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/designpatternsofday/singleton/SingletonRunnable.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.designpatternsofday.singleton;
2 |
3 | public class SingletonRunnable implements Runnable{
4 | @Override
5 | public void run() {
6 |
7 | LazyInitializationNonThreadSafeSingleton instance = LazyInitializationNonThreadSafeSingleton.getInstance();
8 |
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/encapsulation/Engine.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.encapsulation;
2 |
3 | public class Engine {
4 |
5 | private float temperature;
6 | private short activePistonCount;
7 | private boolean status = false;
8 |
9 | public Engine() {
10 | this.temperature = 0.0f;
11 | this.activePistonCount = 0;
12 | }
13 |
14 | public void start() {
15 | this.status = true;
16 | this.activePistonCount = 4;
17 |
18 | var thread = new Thread(() -> {
19 | while (status) {
20 | temperature += 55;
21 |
22 | try {
23 | Thread.sleep(2500);
24 | } catch (InterruptedException e) {
25 | Thread.currentThread().interrupt();
26 | e.printStackTrace();
27 | }
28 | }
29 | });
30 | thread.start();
31 | }
32 |
33 | public void stop() {
34 | this.status = false;
35 | this.activePistonCount = 0;
36 | }
37 |
38 | private void freezeTemperature(float freezeValue) {
39 | this.temperature -= freezeValue;
40 | }
41 |
42 | public boolean getStatus() {
43 | return this.status;
44 | }
45 |
46 | public int getActivePistonCount() {
47 | return this.activePistonCount;
48 | }
49 |
50 | public float getTemperature() {
51 | return this.temperature;
52 | }
53 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/encapsulation/Main.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.encapsulation;
2 |
3 | /**
4 | * Username = baranbuyuk
5 | * Date = 30.07.2021 00:39
6 | **/
7 | public class Main {
8 | public static void main(String[] args) {
9 | Engine engine = new Engine();
10 | engine.start();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/inheritance/hiyerarchical/Main.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.inheritance.hiyerarchical;
2 |
3 |
4 |
5 | /**
6 | * Username = baranbuyuk
7 | * Date = 29.07.2021 22:43
8 | **/
9 |
10 | import dev.patika.spring.inheritance.single.Human;
11 | import dev.patika.spring.inheritance.single.Student;
12 |
13 | /**
14 | * Below topics should be mention in the presentation
15 | * 1- How can i add new behavior specific class?
16 | * 2- How can I access to fields of parent classes?
17 | */
18 | public class Main {
19 |
20 | public static void main(String[] args) {
21 |
22 | Human player = new Player("Player", 25);
23 | player.showInfo();
24 |
25 | // There is a method in the player class which name is getTeam() but doesnt appear for now, how can i access it?
26 | //player.getTeam();
27 |
28 | Human teacher = new Teacher("Teacher", 45);
29 | teacher.showInfo();
30 |
31 | Human student = new Student("Student", 50);
32 | student.showInfo();
33 |
34 | //as you see, we have three different classes which are Teacher, Person, Student and all of them extended from Human class
35 | // Actually, all of them is a Human and they have showInfo() behavior from Human class.
36 | // That's Inheritance.
37 |
38 |
39 | // any question?
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/inheritance/hiyerarchical/Player.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.inheritance.hiyerarchical;
2 |
3 |
4 | import dev.patika.spring.inheritance.single.Human;
5 |
6 | /**
7 | * Username = baranbuyuk
8 | * Date = 29.07.2021 22:42
9 | **/
10 | public class Player extends Human {
11 |
12 |
13 | public Player(String name, int age) {
14 | super(name, age);
15 | }
16 |
17 | public String getTeam() {
18 | return "Real Madrid";
19 | }
20 |
21 | @Override
22 | public void showInfo() {
23 | System.out.println("Player{" +
24 | "name='" + super.getName() + '\'' +
25 | ", age=" + super.getAge() +
26 | '}');
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/inheritance/hiyerarchical/Teacher.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.inheritance.hiyerarchical;
2 |
3 |
4 | import dev.patika.spring.inheritance.single.Human;
5 |
6 | /**
7 | * Username = baranbuyuk
8 | * Date = 29.07.2021 22:41
9 | **/
10 | public class Teacher extends Human {
11 |
12 | public Teacher(String name, int age) {
13 | super(name, age);
14 | }
15 |
16 | @Override
17 | public void showInfo() {
18 | System.out.println("Teacher{" +
19 | "name='" + getName() + '\'' +
20 | ", age=" + getAge() +
21 | '}');
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/inheritance/multilevel/EngineeringStudent.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.inheritance.multilevel;
2 |
3 |
4 | import dev.patika.spring.inheritance.single.Student;
5 |
6 | /**
7 | * Username = baranbuyuk
8 | * Date = 29.07.2021 22:32
9 | **/
10 | public class EngineeringStudent extends Student {
11 |
12 |
13 | public EngineeringStudent(String name, int age) {
14 | super(name, age);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/inheritance/multilevel/Main.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.inheritance.multilevel;
2 |
3 | import dev.patika.spring.inheritance.single.Human;
4 | import dev.patika.spring.inheritance.single.Student;
5 |
6 | /**
7 | * Username = baranbuyuk
8 | * Date = 29.07.2021 22:32
9 | **/
10 | public class Main {
11 |
12 | public static void main(String[] args) {
13 |
14 | Human human = new Human("Human", 50);
15 | human.showInfo();
16 |
17 | Human student = new Student("Student", 18);
18 | student.showInfo();
19 |
20 | // mention about the super keyword in showInfo() method in the engineering student class
21 | Human engineeringStudent = new EngineeringStudent("EngineeringStudent", 22);
22 | engineeringStudent.showInfo();
23 |
24 | // if we can look from multiple inheritance view, Human is Base Class, The Student is intermediatory Class and Engineering Student is Derived Class
25 | // in addition to, Student is-a human, Engineering is a Student and also is a human.
26 |
27 | // any question?
28 |
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/inheritance/single/Human.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.inheritance.single;
2 |
3 | /**
4 | * Username = baranbuyuk
5 | * Date = 29.07.2021 22:05
6 | **/
7 | public class Human {
8 |
9 | private final String name;
10 | private final int age;
11 |
12 |
13 | public Human(String name, int age) {
14 | this.name = name;
15 | this.age = age;
16 | }
17 |
18 | public void showInfo() {
19 | System.out.println("Human{" +
20 | "name='" + name + '\'' +
21 | ", age=" + age +
22 | '}');
23 | }
24 |
25 | public String getName() {
26 | return name;
27 | }
28 |
29 | public int getAge() {
30 | return age;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/inheritance/single/Main.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.inheritance.single;
2 |
3 | /**
4 | * Username = baranbuyuk
5 | * Date = 29.07.2021 22:11
6 | **/
7 |
8 | /**
9 | * Below topics should mention
10 | * 1- What is Parent - Child relation
11 | * 2- What is super() keyword and how it works and what is purpose of it?
12 | * 3- instance of keyword
13 | */
14 | public class Main {
15 |
16 | public static void main(String[] args) {
17 |
18 | //We are creating a human instance from Human class.
19 | var human = new Human("Baran", 50);
20 | human.showInfo();
21 |
22 | //We are creating a Human instance from Student class.
23 | //Because we know that the Student class child class of Human.We can say that Student is a Human.
24 | //View from Inheritance approach we can say that there is IS-A relation between Human and Student class
25 | var student = new Student("Student", 18);
26 |
27 | //Now, when we call showInfo method, JVM will know that is instance of a Student and JVM will call the showInfo method in the student class.
28 | student.getStudentNumber();
29 |
30 |
31 | // any question?
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/inheritance/single/Student.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.inheritance.single;
2 |
3 | /**
4 | * Username = baranbuyuk
5 | * Date = 29.07.2021 22:09
6 | **/
7 | public class Student extends Human {
8 |
9 |
10 | public Student(String name, int age) {
11 | super(name, age);
12 | }
13 |
14 | public Integer getStudentNumber() {
15 | return 10123;
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/order/CreateOrderService.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.order;
2 |
3 | public interface CreateOrderService {
4 |
5 | void create();
6 | }
7 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/order/CreateOrderServiceImpl.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.order;
2 |
3 |
4 | public class CreateOrderServiceImpl implements CreateOrderService {
5 |
6 | CustomerBalanceChecker customerBalanceChecker = new NoCustomerBalanceChecker();
7 |
8 |
9 | @Override
10 | public void create() {
11 | // Siparişi kontrol et
12 | // Siparişin ürünlerini kontrol
13 | // Discount uygula
14 | /** Customer customer = new Customer();
15 | // T0 -> Müşterinin bakiyesi 100 TL'den büyük olmalı, değilse sipariş alamaz. ( PATRON )
16 | //V1
17 | if (customer.getBalance() <= 100) {
18 | throw new RuntimeException("Müşterinin bakiyesi 100'lten büyük olmnalı");
19 | }
20 | customerBalanceChecker.check(customer);
21 | // T1 -> Müşterinin bakiyesi 0 bile olsa alınabilir ( CEO )
22 | //V2
23 | if (customer.getBalance() < 0) {
24 | throw new RuntimeException("Müşterinin bakiyesi 0'küçük olamaz";
25 | }
26 | // T2 -> Müşterinin bakiyesi negatif olsa bile sipariş alınabilir ( Last Ceo )
27 |
28 | //V3
29 | if (customer.getBalance() < 0) {
30 | throw new RuntimeException("Müşterinin bakiyesi 0'küçük olamaz")
31 | }**/
32 |
33 |
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/order/CustomerBalanceChecker.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.order;
2 |
3 | public interface CustomerBalanceChecker {
4 |
5 | // void check(Customer customer) throws Exception;
6 | }
7 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/order/DefaultCustomerBalanceCheckerImpl.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.order;
2 |
3 | public class DefaultCustomerBalanceCheckerImpl implements CustomerBalanceChecker {
4 | /* @Override
5 | public void check(Customer customer) throws Exception {
6 |
7 | if (customer != null) {
8 | double balance = customer.getBalance();
9 | if (balance <= 100) {
10 | throw new RuntimeException("bla bla bla");
11 | }
12 | }
13 | }*/
14 | }
15 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/order/NoCustomerBalanceChecker.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.order;
2 |
3 | public class NoCustomerBalanceChecker implements CustomerBalanceChecker {
4 | /* @Override
5 | public void check(Customer customer) throws Exception {
6 | // there is no op..
7 | },*/
8 | }
9 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/order/ZeroCustomerBalanceCheckerImpl.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.order;
2 |
3 | public class ZeroCustomerBalanceCheckerImpl implements CustomerBalanceChecker {
4 | /*@Override
5 | public void check(Customer customer) throws Exception {
6 | if (customer != null) {
7 | double balance = customer.getBalance();
8 | if (balance <= 0 {
9 | throw new RuntimeException("bla bla bla");
10 | }
11 | }
12 | }*/
13 | }
14 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/polyphormism/Calculator.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.polyphormism;
2 |
3 | /**
4 | * Username = baranbuyuk
5 | * Date = 30.07.2021 00:28
6 | **/
7 |
8 | /**
9 | * 1- What is final keyword on class definition?
10 | * 2- How to JVM understand differences between two or tree method which are same name ?
11 | */
12 | public final class Calculator {
13 |
14 | private Calculator() {
15 | }
16 |
17 | public static int sum(int x, int y) {
18 | return x + y;
19 | }
20 |
21 | public static int sum(int y, int x, int z) {
22 | return x + y + z;
23 | }
24 |
25 | public static int sum(int... numbers) {
26 | var sumOfNumbers = 0;
27 | for (var number : numbers) {
28 | sumOfNumbers += number;
29 | }
30 | return sumOfNumbers;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/polyphormism/Main.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.polyphormism;
2 |
3 | /**
4 | * Username = baranbuyuk
5 | * Date = 30.07.2021 00:36
6 | **/
7 | public class Main {
8 |
9 | public static void main(String[] args) {
10 |
11 | Calculator.sum(1, 2);
12 | Calculator.sum(2, 5);
13 | Calculator.sum(1, 2, 3);
14 |
15 | Calculator.sum(Calculator.sum(1, 2), Calculator.sum(1, 2, 3));
16 |
17 | Calculator.sum(Calculator.sum(1, Calculator.sum(1, 2), Calculator.sum(1, 2)), 2);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/dip/bad/Caller.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.dip.bad;
2 |
3 | import java.util.Arrays;
4 |
5 | public class Caller {
6 |
7 | public static void main(String[] args) {
8 |
9 | SMS sms = new SMS();
10 | SMS sms2 = new SMS();
11 | SMS sms3 = new SMS();
12 | SMS sms4 = new SMS();
13 | Email email = new Email();
14 | Email email2 = new Email();
15 | Letter letter = new Letter();
16 |
17 | Notification notification = new Notification(Arrays.asList(email, email2),
18 | Arrays.asList(sms, sms2, sms3, sms4), Arrays.asList(letter));
19 | notification.notifyUser();
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/dip/bad/Email.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.dip.bad;
2 |
3 | public class Email {
4 |
5 | public void sendMail() {
6 | //Send emeail
7 | }
8 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/dip/bad/Letter.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.dip.bad;
2 |
3 | public class Letter {
4 |
5 |
6 | public void sendLetter() {
7 | // mektup gönderdim..
8 | }
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/dip/bad/Notification.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.dip.bad;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class Notification {
7 |
8 | private final List emails;
9 | private final List sms;
10 | private final List letters;
11 |
12 | public Notification(List emails, List sms, List letters) {
13 | this.emails = emails;
14 | this.sms = sms;
15 | this.letters = letters;
16 | }
17 |
18 | public void notifyUser() {
19 | emails.forEach(Email::sendMail);
20 | sms.forEach(SMS::sendSMS);
21 | letters.forEach(Letter::sendLetter);
22 | }
23 |
24 |
25 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/dip/bad/SMS.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.dip.bad;
2 |
3 | public class SMS {
4 | public void sendSMS() {
5 | //Send sms
6 | }
7 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/dip/good/Caller.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.dip.good;
2 |
3 | import java.util.Arrays;
4 | import java.util.Collections;
5 |
6 | public class Caller {
7 |
8 | public static void main(String[] args) {
9 | Message sms = new SMS("Merhaba", 534444);
10 | Message sms2 = new SMS("Merhaba", 534444);
11 | Message sms3 = new SMS("Merhaba", 534444);
12 | Message sms4 = new SMS("Merhaba", 534444);
13 | Message email = new Email("message", "baran@gmail.com", Collections.emptyList(), new byte[]{});
14 | Message email2 = new Email("message", "baran@gmail.com", Collections.emptyList(), new byte[]{});
15 | Message email3 = new Email("message", "baran@gmail.com", Collections.emptyList(), new byte[]{});
16 | Message letter = new Letter();
17 |
18 | Notification notification = new Notification(Arrays.asList(sms, sms2, sms3, sms4, email, email2, email3,letter));
19 | notification.send();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/dip/good/Email.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.dip.good;
2 |
3 | import java.util.List;
4 |
5 | public class Email implements Message {
6 |
7 |
8 | private String text;
9 | private String to;
10 | private List cc;
11 | private byte[] attaches;
12 |
13 | public Email(String text, String to, List cc, byte[] attaches) {
14 | this.text = text;
15 | this.to = to;
16 | this.cc = cc;
17 | this.attaches = attaches;
18 | }
19 |
20 | @Override
21 | public void sendMessage() {
22 | sendEmail();
23 | }
24 |
25 | private void sendEmail() {
26 | //Send email
27 | }
28 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/dip/good/Letter.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.dip.good;
2 |
3 | public class Letter implements Message{
4 | @Override
5 | public void sendMessage() {
6 | // mektup
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/dip/good/Message.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.dip.good;
2 |
3 | public interface Message {
4 | void sendMessage();
5 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/dip/good/Notification.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.dip.good;
2 |
3 | import java.util.List;
4 |
5 | public class Notification {
6 |
7 | private List messages;
8 |
9 | public Notification(List messages) {
10 | this.messages = messages;
11 | }
12 |
13 | public void send() {
14 | for (Message message : messages) {
15 | message.sendMessage();
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/dip/good/SMS.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.dip.good;
2 |
3 | public class SMS implements Message {
4 |
5 |
6 | private String text;
7 | private Integer phoneNumber;
8 |
9 | public SMS(String text, Integer phoneNumber) {
10 | this.text = text;
11 | this.phoneNumber = phoneNumber;
12 | }
13 |
14 | @Override
15 | public void sendMessage() {
16 | sendSMS();
17 | }
18 |
19 | private void sendSMS() {
20 | //Send sms
21 | }
22 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/isp/bad/Button.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.isp.bad;
2 |
3 | import javax.swing.text.View;
4 |
5 | public class Button implements OnClickListener {
6 | @Override
7 | public void onClick(View vi) {
8 | System.out.println("Clicked");
9 | }
10 |
11 | @Override
12 | public void onLongClick(View view) {
13 | System.out.println("On Long Clicked");
14 | }
15 |
16 | @Override
17 | public void onShortClick(View view) {
18 | // no -op
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/isp/bad/OnClickListener.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.isp.bad;
2 |
3 | import javax.swing.text.View;
4 |
5 | public interface OnClickListener {
6 |
7 | void onClick(View vi);
8 |
9 | void onLongClick(View view);
10 |
11 | void onShortClick(View view);
12 | }
13 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/isp/bad/TextBox.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.isp.bad;
2 |
3 | import javax.swing.text.View;
4 |
5 | public class TextBox implements OnClickListener {
6 | @Override
7 | public void onClick(View vi) {
8 | System.out.println("Clicked");
9 | }
10 |
11 | @Override
12 | public void onLongClick(View view) {
13 | //The text box has no long click behaviour.
14 | }
15 |
16 | @Override
17 | public void onShortClick(View view) {
18 | System.out.println("On short clicked");
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/isp/good/Button.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.isp.good;
2 |
3 | import javax.swing.text.View;
4 |
5 | public class Button implements OnClickListener, OnLongClickListener {
6 | @Override
7 | public void onClick(View view) {
8 | System.out.println("Clicked");
9 | }
10 |
11 | @Override
12 | public void onLongClick(View view) {
13 | System.out.println("Long Clicked");
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/isp/good/Listener.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.isp.good;
2 |
3 | public interface Listener {
4 | }
5 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/isp/good/OnClickListener.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.isp.good;
2 |
3 | import javax.swing.text.View;
4 |
5 | public interface OnClickListener extends Listener{
6 |
7 | void onClick(View view);
8 | }
9 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/isp/good/OnLongClickListener.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.isp.good;
2 |
3 | import javax.swing.text.View;
4 |
5 | public interface OnLongClickListener extends Listener {
6 |
7 | void onLongClick(View view);
8 | }
9 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/isp/good/OnShortClickListener.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.isp.good;
2 |
3 | import javax.swing.text.View;
4 |
5 | public interface OnShortClickListener extends Listener{
6 |
7 | void onShortClick(View view);
8 | }
9 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/isp/good/Text.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.isp.good;
2 |
3 | import javax.swing.text.View;
4 |
5 | public class Text implements OnClickListener, OnShortClickListener {
6 | @Override
7 | public void onClick(View view) {
8 | System.out.println("Clicked");
9 | }
10 |
11 | @Override
12 | public void onShortClick(View view) {
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/lsp/bad/Bird.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.lsp.bad;
2 |
3 | public interface Bird {
4 |
5 | void fly();
6 | }
7 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/lsp/bad/Duck.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.lsp.bad;
2 |
3 | public class Duck implements Bird {
4 | @Override
5 | public void fly() {
6 | System.out.println("I can fly..");
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/lsp/bad/Ostrich.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.lsp.bad;
2 |
3 | public class Ostrich implements Bird {
4 | @Override
5 | public void fly() {
6 | // no-op
7 | }
8 |
9 | //Normally Ostrich can't fly, but we are saying that can fly. This is an exception.
10 | //According to LSP, there should not be an exception in child class implementation.
11 | }
12 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/lsp/good/Bird.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.lsp.good;
2 |
3 |
4 | public interface Bird {
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/lsp/good/Duck.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.lsp.good;
2 |
3 | public class Duck implements Flyable {
4 |
5 | @Override
6 | public void fly() {
7 | System.out.println("I can fly..");
8 |
9 | }
10 |
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/lsp/good/Flyable.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.lsp.good;
2 |
3 | import javax.management.RuntimeErrorException;
4 | import java.io.IOException;
5 |
6 | public interface Flyable extends Bird {
7 |
8 | void fly() throws IOException;
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/lsp/good/Ostrich.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.lsp.good;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 |
6 | public class Ostrich implements Walk {
7 |
8 |
9 | @Override
10 | public void walking() throws IOException {
11 | File.createTempFile("", "");
12 |
13 |
14 | }
15 |
16 | public static void main(String[] args) {
17 | Walk ost = new Ostrich();
18 |
19 | try {
20 | ost.walking();
21 | } catch (Exception e) {
22 | e.printStackTrace();
23 | }
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/lsp/good/Walk.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.lsp.good;
2 |
3 | import javax.swing.text.ChangedCharSetException;
4 | import java.io.IOException;
5 |
6 | public interface Walk extends Bird{
7 |
8 | void walking() throws Exception, ChangedCharSetException;
9 | }
10 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/lsp/lnew/Human.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.lsp.lnew;
2 |
3 | public interface Human {
4 |
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/lsp/lnew/HumanInPandemicTimes.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.lsp.lnew;
2 |
3 | public interface HumanInPandemicTimes extends Human{
4 |
5 | void breathWithMask();
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/lsp/lnew/HumanInWarTimes.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.lsp.lnew;
2 |
3 | public interface HumanInWarTimes extends Human{
4 |
5 | void breathN95Mask();
6 | }
7 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/lsp/lnew/HumanNotInPandemicTimes.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.lsp.lnew;
2 |
3 | public interface HumanNotInPandemicTimes extends Human{
4 |
5 | void breath();
6 | }
7 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/lsp/lnew/Student.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.lsp.lnew;
2 |
3 | public class Student implements HumanInWarTimes, HumanInPandemicTimes {
4 |
5 |
6 | @Override
7 | public void breathN95Mask() {
8 |
9 | }
10 |
11 | @Override
12 | public void breathWithMask() {
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/ocp/bad/Addition.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.ocp.bad;
2 |
3 | public class Addition implements CalculatorOperation {
4 | private double left;
5 | private double right;
6 | private double result = 0.0;
7 |
8 | public Addition(double left, double right) {
9 | this.left = left;
10 | this.right = right;
11 | }
12 |
13 | public double getLeft() {
14 | return left;
15 | }
16 |
17 | public void setLeft(double left) {
18 | this.left = left;
19 | }
20 |
21 | public double getRight() {
22 | return right;
23 | }
24 |
25 | public void setRight(double right) {
26 | this.right = right;
27 | }
28 |
29 | public double getResult() {
30 | return result;
31 | }
32 |
33 | public void setResult(double result) {
34 | this.result = result;
35 | }
36 |
37 | // getters and setters
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/ocp/bad/Calculator.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.ocp.bad;
2 |
3 | import java.security.InvalidParameterException;
4 |
5 | public class Calculator {
6 |
7 | public void calculate(CalculatorOperation operation) {
8 | if (operation == null) {
9 | throw new InvalidParameterException("Can not perform operation");
10 | }
11 | if (operation instanceof Addition addition) {
12 | addition.setResult(addition.getLeft() + addition.getRight());
13 | } else if (operation instanceof Subtraction subtraction) {
14 | subtraction.setResult(subtraction.getLeft() - subtraction.getRight());
15 | } else if (operation instanceof Division division) {
16 | division.setResult(division.getLeft() / division.getRight());
17 | }
18 | //let's think about we will add a new feature that divide operation.
19 | //If we want to add new divide feature to this operation, we have to change this code block.
20 | //The new might cause a some bugs after add operation. This is not good OCP!
21 | }
22 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/ocp/bad/CalculatorOperation.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.ocp.bad;
2 |
3 | public interface CalculatorOperation {
4 |
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/ocp/bad/Division.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.ocp.bad;
2 |
3 | public class Division implements CalculatorOperation{
4 |
5 | private double left;
6 | private double right;
7 | private double result = 0.0;
8 |
9 | public Division(double left, double right) {
10 | this.left = left;
11 | this.right = right;
12 | }
13 |
14 | public double getLeft() {
15 | return left;
16 | }
17 |
18 | public void setLeft(double left) {
19 | this.left = left;
20 | }
21 |
22 | public double getRight() {
23 | return right;
24 | }
25 |
26 | public void setRight(double right) {
27 | this.right = right;
28 | }
29 |
30 | public double getResult() {
31 | return result;
32 | }
33 |
34 | public void setResult(double result) {
35 | this.result = result;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/ocp/bad/Main.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.ocp.bad;
2 |
3 | public class Main {
4 |
5 | public static void main(String[] args) {
6 | CalculatorOperation addition = new Addition(0, 2);
7 | CalculatorOperation subtract = new Subtraction(0, 2);
8 | Calculator calculator = new Calculator();
9 | calculator.calculate(addition);
10 | calculator.calculate(subtract);
11 | CalculatorOperation division = new Division(12, 2);
12 | calculator.calculate(division);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/ocp/bad/Subtraction.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.ocp.bad;
2 |
3 | public class Subtraction implements CalculatorOperation {
4 |
5 | private double left;
6 | private double right;
7 | private double result = 0.0;
8 |
9 | public Subtraction(double left, double right) {
10 | this.left = left;
11 | this.right = right;
12 | }
13 |
14 | public double getLeft() {
15 | return left;
16 | }
17 |
18 | public void setLeft(double left) {
19 | this.left = left;
20 | }
21 |
22 | public double getRight() {
23 | return right;
24 | }
25 |
26 | public void setRight(double right) {
27 | this.right = right;
28 | }
29 |
30 | public double getResult() {
31 | return result;
32 | }
33 |
34 | public void setResult(double result) {
35 | this.result = result;
36 | }
37 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/ocp/good/Addition.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.ocp.good;
2 |
3 | public class Addition implements CalculatorOperation {
4 | private double left;
5 | private double right;
6 | private double result;
7 |
8 | public Addition(double left, double right) {
9 | this.left = left;
10 | this.right = right;
11 | }
12 |
13 | @Override
14 | public void perform() {
15 | result = left + right;
16 | }
17 |
18 | public double getLeft() {
19 | return left;
20 | }
21 |
22 | public void setLeft(double left) {
23 | this.left = left;
24 | }
25 |
26 | public double getRight() {
27 | return right;
28 | }
29 |
30 | public void setRight(double right) {
31 | this.right = right;
32 | }
33 |
34 | public double getResult() {
35 | return result;
36 | }
37 |
38 | public void setResult(double result) {
39 | this.result = result;
40 | }
41 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/ocp/good/Calculator.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.ocp.good;
2 |
3 | import java.security.InvalidParameterException;
4 |
5 | public class Calculator {
6 |
7 | public void calculate(CalculatorOperation operation) {
8 | if (operation == null) {
9 | throw new InvalidParameterException("Cannot perform operation");
10 | }
11 | operation.perform();
12 |
13 | // we took calculation responsibility
14 | // from this code block and given to implementations of calculator operation
15 | // When new feature is added such as multiply, we will just create a new implementation of CalculatorOperation.
16 | }
17 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/ocp/good/CalculatorOperation.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.ocp.good;
2 |
3 | public interface CalculatorOperation {
4 |
5 | void perform();
6 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/ocp/good/Division.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.ocp.good;
2 |
3 | public class Division implements CalculatorOperation {
4 | private double left;
5 | private double right;
6 | private double result;
7 |
8 | public Division(double left, double right) {
9 | this.left = left;
10 | this.right = right;
11 | }
12 |
13 | @Override
14 | public void perform() {
15 | if (right != 0) {
16 | result = left / right;
17 | }
18 | }
19 |
20 | public double getLeft() {
21 | return left;
22 | }
23 |
24 | public void setLeft(double left) {
25 | this.left = left;
26 | }
27 |
28 | public double getRight() {
29 | return right;
30 | }
31 |
32 | public void setRight(double right) {
33 | this.right = right;
34 | }
35 |
36 | public double getResult() {
37 | return result;
38 | }
39 |
40 | public void setResult(double result) {
41 | this.result = result;
42 | }
43 | }
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/ocp/good/Main.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.ocp.good;
2 |
3 | public class Main {
4 | public static void main(String[] args) {
5 | CalculatorOperation divide = new Division(100, 2);
6 | CalculatorOperation add = new Addition(2, 2);
7 | Calculator calculator = new Calculator();
8 | calculator.calculate(divide);
9 | calculator.calculate(add);
10 | CalculatorOperation subtraction = new Subtraction(12, 22);
11 | calculator.calculate(subtraction);
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/ocp/good/Subtraction.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.ocp.good;
2 |
3 | public class Subtraction implements CalculatorOperation {
4 |
5 | private double left;
6 | private double right;
7 | private double result;
8 |
9 | public Subtraction(double left, double right) {
10 | this.left = left;
11 | this.right = right;
12 | }
13 |
14 | @Override
15 | public void perform() {
16 | result = left + right;
17 | }
18 |
19 | public double getLeft() {
20 | return left;
21 | }
22 |
23 | public void setLeft(double left) {
24 | this.left = left;
25 | }
26 |
27 | public double getRight() {
28 | return right;
29 | }
30 |
31 | public void setRight(double right) {
32 | this.right = right;
33 | }
34 |
35 | public double getResult() {
36 | return result;
37 | }
38 |
39 | public void setResult(double result) {
40 | this.result = result;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/srp/bad/BadSRPApproach.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.srp.bad;
2 |
3 | import java.sql.Connection;
4 | import java.util.List;
5 |
6 | public interface BadSRPApproach {
7 |
8 | Connection open();
9 |
10 | List fetchFromData(Class returnClass, String query);
11 |
12 | void writeDataToExternalFile(byte[] data);
13 | }
14 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/srp/good/DataWriter.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.srp.good;
2 |
3 | public interface DataWriter {
4 |
5 | void write(byte[] data);
6 | }
7 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/srp/good/DatabaseConnection.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.srp.good;
2 |
3 | import java.sql.Connection;
4 |
5 | public interface DatabaseConnection {
6 |
7 | Connection open();
8 |
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/OOP-SOLID/src/dev/patika/spring/solid/srp/good/QueryExecutor.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.solid.srp.good;
2 |
3 | import java.util.List;
4 |
5 | public interface QueryExecutor {
6 |
7 | List execute(Class returnClass, String query);
8 | }
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # examples
2 |
--------------------------------------------------------------------------------
/Spring Java Egitimi.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/Spring Java Egitimi.pptx
--------------------------------------------------------------------------------
/SpringBootNorma.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/SpringBootNorma.pptx
--------------------------------------------------------------------------------
/jpa-examples/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/jpa-examples/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/jpa-examples/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/jpa-examples/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/jpa-examples/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.6.6
9 |
10 |
11 | org.patikadev
12 | jpa-examples
13 | 0.0.1-SNAPSHOT
14 | jpa-examples
15 | jpa-examples
16 |
17 | 17
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-data-jpa
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 | com.h2database
32 | h2
33 | runtime
34 |
35 |
36 | org.projectlombok
37 | lombok
38 | true
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-starter-test
43 | test
44 |
45 |
46 |
47 |
48 |
49 |
50 | org.springframework.boot
51 | spring-boot-maven-plugin
52 |
53 |
54 |
55 | org.projectlombok
56 | lombok
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/jpa-examples/src/main/java/org/patikadev/jpaexamples/JpaExamplesApplication.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.jpaexamples;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class JpaExamplesApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(JpaExamplesApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/jpa-examples/src/main/java/org/patikadev/jpaexamples/entity/BaseEntity.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.jpaexamples.entity;
2 |
3 |
4 | import lombok.Getter;
5 |
6 | import javax.persistence.GeneratedValue;
7 | import javax.persistence.GenerationType;
8 | import javax.persistence.Id;
9 | import javax.persistence.MappedSuperclass;
10 |
11 | @Getter
12 | @MappedSuperclass
13 | public abstract class BaseEntity {
14 |
15 | @Id
16 | @GeneratedValue(strategy = GenerationType.IDENTITY)
17 | private Long id;
18 |
19 |
20 | // createdAt
21 | // createdBy
22 | // updatedAt
23 | // updatedBy
24 | // deletedAt
25 | // deletedBy
26 | }
27 |
--------------------------------------------------------------------------------
/jpa-examples/src/main/java/org/patikadev/jpaexamples/entity/BaseExtendedEntity.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.jpaexamples.entity;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 |
6 | import javax.persistence.Temporal;
7 | import javax.persistence.TemporalType;
8 | import java.util.Date;
9 |
10 | @Getter
11 | @Setter
12 | public class BaseExtendedEntity extends BaseEntity {
13 |
14 | @Temporal(TemporalType.DATE)
15 | private Date createdAt;
16 | @Temporal(TemporalType.DATE)
17 | private Date updatedAt;
18 | @Temporal(TemporalType.DATE)
19 | private Date deletedAt;
20 |
21 | private String createdBy;
22 | private String updatedBy;
23 | private String deletedBy;
24 | }
25 |
--------------------------------------------------------------------------------
/jpa-examples/src/main/java/org/patikadev/jpaexamples/entity/Course.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.jpaexamples.entity;
2 |
3 |
4 | import lombok.Getter;
5 | import lombok.Setter;
6 |
7 | import javax.persistence.Entity;
8 |
9 |
10 | @Entity
11 | @Getter
12 | @Setter
13 | public class Course extends BaseEntity {
14 |
15 | private String name;
16 | private String code;
17 | }
18 |
--------------------------------------------------------------------------------
/jpa-examples/src/main/java/org/patikadev/jpaexamples/entity/DepartmentEnum.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.jpaexamples.entity;
2 |
3 | public enum DepartmentEnum {
4 |
5 | PYHSICS,
6 | PYSHOCOLOGY,
7 | MATHEMATICS;
8 | }
9 |
--------------------------------------------------------------------------------
/jpa-examples/src/main/java/org/patikadev/jpaexamples/entity/Student.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.jpaexamples.entity;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 |
6 | import javax.persistence.*;
7 | import java.util.Date;
8 | import java.util.HashSet;
9 | import java.util.Set;
10 |
11 |
12 | @Getter
13 | @Entity
14 | public class Student extends BaseExtendedEntity {
15 |
16 | // 1 - NoArgsConstructor olmak zorunda..
17 | // 2 - @Id anotasyonun kullanılıyor olması lazım.
18 | // 3- Defaullta get - setter olmalı..
19 |
20 | @Setter
21 | private Long number;
22 |
23 | @Setter
24 | @Column(length = 50)
25 | private String name;
26 |
27 | @Setter
28 | @Column(length = 60)
29 | private String lastName;
30 |
31 | @Setter
32 | @Enumerated(EnumType.STRING)
33 | @Column(length = 20)
34 | private DepartmentEnum department;
35 |
36 | @Setter
37 | @Temporal(TemporalType.DATE)
38 | private Date birthDate;
39 |
40 | @OneToOne(optional = false)
41 | private StudentAddress studentAddress;
42 |
43 | @ManyToMany
44 | private Set courses = new HashSet<>();
45 |
46 |
47 | public void addStudentAddress(StudentAddress studentAddress) {
48 | this.studentAddress = studentAddress;
49 | }
50 |
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/jpa-examples/src/main/java/org/patikadev/jpaexamples/entity/StudentAddress.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.jpaexamples.entity;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 |
6 | import javax.persistence.Entity;
7 |
8 | @Getter
9 | @Setter
10 | @Entity
11 | public class StudentAddress extends BaseEntity {
12 |
13 | private String country;
14 | private String city;
15 | private String district;
16 | private String description;
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/jpa-examples/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8080
2 | spring.datasource.url=jdbc:h2:mem:jpa-example
3 | spring.datasource.driverClassName=org.h2.Driver
4 | spring.datasource.username=sa
5 | spring.datasource.password=
6 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
7 | spring.jpa.hibernate.ddl-auto=create-drop
8 | spring.jpa.show-sql=true
9 | spring.h2.console.enabled=true
10 | spring.h2.console.path=/h2
11 |
--------------------------------------------------------------------------------
/jpa-examples/src/test/java/org/patikadev/jpaexamples/JpaExamplesApplicationTests.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.jpaexamples;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class JpaExamplesApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/order-example/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/order-example/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/order-example/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/order-example/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/order-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.6.6
9 |
10 |
11 | org.patikadev
12 | order-example
13 | 0.0.1-SNAPSHOT
14 | order-example
15 | order-example
16 |
17 | 17
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-data-jpa
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter-web
27 |
28 |
29 |
30 | com.h2database
31 | h2
32 | runtime
33 |
34 |
35 | org.projectlombok
36 | lombok
37 | true
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-starter-test
42 | test
43 |
44 |
45 |
46 |
47 |
48 |
49 | org.springframework.boot
50 | spring-boot-maven-plugin
51 |
52 |
53 |
54 | org.projectlombok
55 | lombok
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/OrderExampleApplication.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class OrderExampleApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(OrderExampleApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/controller/BaseControllerAdvice.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.controller;
2 |
3 | import org.patikadev.orderexample.exception.BaseException;
4 | import org.springframework.http.HttpStatus;
5 | import org.springframework.http.ResponseEntity;
6 | import org.springframework.web.bind.annotation.ExceptionHandler;
7 | import org.springframework.web.bind.annotation.ResponseStatus;
8 | import org.springframework.web.bind.annotation.RestControllerAdvice;
9 |
10 | @RestControllerAdvice
11 | public class BaseControllerAdvice {
12 |
13 |
14 | @ResponseStatus(value = HttpStatus.BAD_REQUEST)
15 | @ExceptionHandler(BaseException.class)
16 | public ResponseEntity> onBaseExceptionHandled(BaseException baseException) {
17 | return ResponseEntity.badRequest().body(new ApiError(baseException.getMessage()));
18 | }
19 |
20 | @ResponseStatus(value = HttpStatus.BAD_REQUEST)
21 | @ExceptionHandler(RuntimeException.class)
22 | public ResponseEntity> onRuntimeExceptionHandled(RuntimeException baseException) {
23 | return ResponseEntity.badRequest().body(new ApiError(baseException.getMessage()));
24 | }
25 |
26 |
27 | public static record ApiError(String errorMessage) {
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/controller/CustomerController.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.controller;
2 |
3 | import lombok.RequiredArgsConstructor;
4 | import org.patikadev.orderexample.dto.CreateCustomerRequestDTO;
5 | import org.patikadev.orderexample.dto.GetCustomersResponseDTO;
6 | import org.patikadev.orderexample.service.CustomerService;
7 | import org.patikadev.orderexample.validator.Validator;
8 | import org.springframework.http.ResponseEntity;
9 | import org.springframework.web.bind.annotation.*;
10 |
11 | import java.util.Collection;
12 |
13 | @RequiredArgsConstructor
14 | @RestController
15 | @RequestMapping("api/customers")
16 | public class CustomerController {
17 |
18 | private final Validator createCustomerValidator;
19 | private final Validator customerIdValidator;
20 | private final CustomerService customerService;
21 |
22 |
23 | @PostMapping
24 | public ResponseEntity> create(@RequestBody CreateCustomerRequestDTO createCustomerRequestDTO) {
25 | createCustomerValidator.validate(createCustomerRequestDTO);
26 | customerService.create(createCustomerRequestDTO);
27 | return ResponseEntity.ok().build();
28 | }
29 |
30 | @GetMapping
31 | public ResponseEntity> getCustomers() {
32 | return ResponseEntity.ok(customerService.getCustomers());
33 | }
34 |
35 | @GetMapping("/{id}")
36 | public ResponseEntity getCustomer(@PathVariable Long id) {
37 | customerIdValidator.validate(id);
38 | return ResponseEntity.ok(customerService.getCustomer(id));
39 | }
40 |
41 | @DeleteMapping("/{id}")
42 | public ResponseEntity> delete(@PathVariable Long id,
43 | @RequestParam(name = "hardDelete", required = false) boolean hardDelete) {
44 | customerIdValidator.validate(id);
45 | customerService.delete(id,hardDelete);
46 | return ResponseEntity.ok().build();
47 | }
48 |
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/converter/CustomerConverter.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.converter;
2 |
3 | import org.patikadev.orderexample.dto.CreateCustomerRequestDTO;
4 | import org.patikadev.orderexample.dto.GetCustomersResponseDTO;
5 | import org.patikadev.orderexample.model.Customer;
6 |
7 | public interface CustomerConverter {
8 |
9 | Customer toCustomer(CreateCustomerRequestDTO createCustomerRequestDTO);
10 |
11 | CreateCustomerRequestDTO toCreateCustomerRequest(Customer customer);
12 |
13 | GetCustomersResponseDTO toGetCustomersResponse(Customer customer);
14 | }
15 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/dto/CreateCustomerRequestDTO.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.dto;
2 |
3 | import org.patikadev.orderexample.model.Gender;
4 |
5 | public record CreateCustomerRequestDTO(String userName, String email, Long identity, Gender gender, String password,
6 | CustomerAddressDTO customerAddress) {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/dto/CustomerAddressDTO.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.dto;
2 |
3 | public record CustomerAddressDTO(String phoneNumber,
4 | String country,
5 | String city,
6 | String postalCode,
7 | String description) {
8 | }
9 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/dto/GetCustomersResponseDTO.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.dto;
2 |
3 | import org.patikadev.orderexample.model.Gender;
4 |
5 | public record GetCustomersResponseDTO(Long id,
6 | String username,
7 | String email,
8 | Gender gender,
9 | CustomerAddressDTO customerAddressDTO) {
10 | }
11 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/exception/BaseException.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.exception;
2 |
3 | public class BaseException extends RuntimeException {
4 |
5 | private final String message;
6 |
7 | public BaseException(String message) {
8 | this.message = message;
9 | }
10 |
11 | @Override
12 | public String getMessage() {
13 | return message;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/exception/BaseValidationException.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.exception;
2 |
3 | public class BaseValidationException extends BaseException {
4 | public BaseValidationException(String message) {
5 | super(message);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/exception/BusinessServiceOperationException.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.exception;
2 |
3 | public final class BusinessServiceOperationException {
4 |
5 | private BusinessServiceOperationException() {
6 | }
7 |
8 | public static class CustomerNotFoundException extends BaseException {
9 | public CustomerNotFoundException(String message) {
10 | super(message);
11 | }
12 | }
13 |
14 | public static class CustomerAlreadyDeletedException extends BaseException {
15 | public CustomerAlreadyDeletedException(String message) {
16 | super(message);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/exception/ValidationOperationException.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.exception;
2 |
3 | public final class ValidationOperationException {
4 |
5 | private ValidationOperationException() {
6 | }
7 |
8 | public static class CustomerNotValidException extends BaseException {
9 | public CustomerNotValidException(String message) {
10 | super(message);
11 | }
12 | }
13 |
14 | public static class ProductNotValidException extends BaseException {
15 | public ProductNotValidException(String message) {
16 | super(message);
17 | }
18 | }
19 |
20 | public static class CustomerIDNotValidException extends BaseException {
21 | public CustomerIDNotValidException(String message) {
22 | super(message);
23 | }
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/model/BaseExtendedModel.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.model;
2 |
3 |
4 | import lombok.Getter;
5 | import lombok.Setter;
6 |
7 | import javax.persistence.Column;
8 | import javax.persistence.MappedSuperclass;
9 | import javax.persistence.Temporal;
10 | import javax.persistence.TemporalType;
11 | import java.util.Date;
12 |
13 | @Getter
14 | @Setter
15 | @MappedSuperclass
16 | public abstract class BaseExtendedModel extends BaseModel {
17 |
18 | @Temporal(value = TemporalType.TIMESTAMP)
19 | private Date createdAt;
20 | @Temporal(value = TemporalType.TIMESTAMP)
21 | private Date updatedAt;
22 | @Temporal(value = TemporalType.TIMESTAMP)
23 | private Date deletedAt;
24 |
25 | @Column(length = 50)
26 | private String createdBy;
27 | @Column(length = 50)
28 | private String updatedBy;
29 | @Column(length = 50)
30 | private String deletedBy;
31 |
32 | private boolean isDeleted;
33 | }
34 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/model/BaseModel.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.model;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 |
6 | import javax.persistence.GeneratedValue;
7 | import javax.persistence.GenerationType;
8 | import javax.persistence.Id;
9 | import javax.persistence.MappedSuperclass;
10 |
11 |
12 | @Getter
13 | @Setter
14 | @MappedSuperclass
15 | public abstract class BaseModel {
16 |
17 | @Id
18 | @GeneratedValue(strategy = GenerationType.IDENTITY)
19 | private Long id;
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/model/Basket.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.model;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 |
6 | import javax.persistence.Column;
7 | import javax.persistence.Entity;
8 | import javax.persistence.OneToMany;
9 | import java.math.BigDecimal;
10 | import java.util.HashSet;
11 | import java.util.Set;
12 |
13 | @Entity
14 | @Getter
15 | @Setter
16 | public class Basket extends BaseModel {
17 |
18 | @Column(nullable = false)
19 | private BigDecimal price;
20 |
21 | private BigDecimal discountPrice = BigDecimal.ZERO;
22 | private BigDecimal taxPrice = BigDecimal.ZERO;
23 | private BigDecimal shippingPrice = BigDecimal.ZERO;
24 |
25 | @Column(nullable = false)
26 | private BigDecimal totalPrice;
27 |
28 | @OneToMany(mappedBy = "basket")
29 | private Set items = new HashSet<>();
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/model/BasketItem.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.model;
2 |
3 |
4 | import lombok.Getter;
5 | import lombok.Setter;
6 |
7 | import javax.persistence.Column;
8 | import javax.persistence.Entity;
9 | import javax.persistence.ManyToOne;
10 | import java.math.BigDecimal;
11 |
12 | @Entity
13 | @Getter
14 | @Setter
15 | public class BasketItem extends BaseModel {
16 |
17 | @ManyToOne(optional = false)
18 | private Basket basket;
19 |
20 | @ManyToOne(optional = false)
21 | private Product product;
22 |
23 | @Column(nullable = false)
24 | private BigDecimal quantity;
25 | @Column(nullable = false)
26 | private BigDecimal price = BigDecimal.ZERO;
27 | private BigDecimal discountPrice = BigDecimal.ZERO;
28 | private BigDecimal taxPrice = BigDecimal.ZERO;
29 | private BigDecimal shippingPrice = BigDecimal.ZERO;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/model/Brand.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.model;
2 |
3 |
4 | import lombok.Getter;
5 | import lombok.Setter;
6 |
7 | import javax.persistence.Entity;
8 |
9 | @Getter
10 | @Setter
11 | @Entity
12 | public class Brand extends BaseModel {
13 |
14 | private String name;
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/model/Category.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.model;
2 |
3 |
4 | import lombok.Getter;
5 | import lombok.Setter;
6 |
7 | import javax.persistence.Entity;
8 | import javax.persistence.OneToOne;
9 |
10 | @Entity
11 | @Getter
12 | @Setter
13 | public class Category extends BaseModel {
14 |
15 | @OneToOne
16 | private Category parent;
17 |
18 | private String name;
19 | }
20 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/model/Customer.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.model;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 |
6 | import javax.persistence.*;
7 |
8 | @Entity
9 | @Getter
10 | @Setter
11 | public class Customer extends BaseExtendedModel {
12 |
13 | private String username;
14 | private String email;
15 | private Long identity;
16 | @Enumerated(EnumType.STRING)
17 | private Gender gender;
18 | private String password;
19 |
20 | @OneToOne(mappedBy = "customer", cascade = CascadeType.ALL, orphanRemoval = true)
21 | private CustomerAddress customerAddress;
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/model/CustomerAddress.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.model;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 |
6 | import javax.persistence.Entity;
7 | import javax.persistence.OneToOne;
8 |
9 | @Entity
10 | @Getter
11 | @Setter
12 | public class CustomerAddress extends BaseModel {
13 |
14 | private String phoneNumber;
15 | private String country;
16 | private String city;
17 | private String postalCode;
18 | private String description;
19 |
20 | @OneToOne
21 | private Customer customer;
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/model/Gender.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.model;
2 |
3 | public enum Gender {
4 |
5 | FEMALE, MALE, OTHER
6 | }
7 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/model/Product.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.model;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 |
6 | import javax.persistence.Entity;
7 | import javax.persistence.ManyToOne;
8 | import java.math.BigDecimal;
9 | import java.util.UUID;
10 |
11 | @Getter
12 | @Setter
13 | @Entity
14 | public class Product extends BaseExtendedModel {
15 |
16 | private String name;
17 | private BigDecimal price;
18 | private UUID barcode;
19 | private String image;
20 |
21 | @ManyToOne
22 | private Brand brand;
23 | @ManyToOne
24 | private Category category;
25 |
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/repository/CustomerRepository.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.repository;
2 |
3 | import org.patikadev.orderexample.model.Customer;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.data.jpa.repository.Query;
6 | import org.springframework.stereotype.Repository;
7 |
8 | import java.util.Collection;
9 |
10 | @Repository
11 | public interface CustomerRepository extends JpaRepository {
12 |
13 | Collection findAllByIsDeleted(boolean deleted);
14 |
15 | @Query("SELECT c FROM Customer c WHERE c.isDeleted = ?1")
16 | Collection findAllCustomersByDeleteStatusByJPQL(boolean status);
17 | }
18 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/service/CustomerService.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.service;
2 |
3 | import org.patikadev.orderexample.dto.CreateCustomerRequestDTO;
4 | import org.patikadev.orderexample.dto.GetCustomersResponseDTO;
5 | import org.patikadev.orderexample.exception.BaseException;
6 |
7 | import java.util.Collection;
8 |
9 | public interface CustomerService {
10 | void create(CreateCustomerRequestDTO customerDTO);
11 |
12 | CreateCustomerRequestDTO getCustomer(Long id) throws BaseException;
13 |
14 | Collection getCustomers();
15 |
16 | void delete(Long id, boolean hardDelete) throws BaseException;
17 | }
18 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/service/CustomerServiceImpl.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.service;
2 |
3 | import lombok.RequiredArgsConstructor;
4 | import lombok.extern.slf4j.Slf4j;
5 | import org.patikadev.orderexample.converter.CustomerConverter;
6 | import org.patikadev.orderexample.dto.CreateCustomerRequestDTO;
7 | import org.patikadev.orderexample.dto.GetCustomersResponseDTO;
8 | import org.patikadev.orderexample.exception.BaseException;
9 | import org.patikadev.orderexample.exception.BusinessServiceOperationException;
10 | import org.patikadev.orderexample.model.Customer;
11 | import org.patikadev.orderexample.repository.CustomerRepository;
12 | import org.springframework.stereotype.Service;
13 |
14 | import java.util.Collection;
15 |
16 | @Service
17 | @RequiredArgsConstructor
18 | @Slf4j
19 | public class CustomerServiceImpl implements CustomerService {
20 |
21 | private final CustomerConverter customerConverter;
22 | private final CustomerRepository customerRepository;
23 |
24 | @Override
25 | public void create(CreateCustomerRequestDTO createCustomerRequestDTO) {
26 | Customer customer = customerConverter.toCustomer(createCustomerRequestDTO);
27 | customerRepository.save(customer);
28 | }
29 |
30 | @Override
31 | public CreateCustomerRequestDTO getCustomer(Long id) throws BaseException {
32 | Customer customer = customerRepository
33 | .findById(id)
34 | .orElseThrow(() -> new BusinessServiceOperationException.CustomerNotFoundException("Customer not found"));
35 | return customerConverter.toCreateCustomerRequest(customer);
36 | }
37 |
38 | @Override
39 | public Collection getCustomers() {
40 | return customerRepository
41 | .findAllCustomersByDeleteStatusByJPQL(false)
42 | .stream()
43 | .map(customerConverter::toGetCustomersResponse)
44 | .toList();
45 | }
46 |
47 | @Override
48 | public void delete(Long id, boolean hardDelete) throws BaseException {
49 | Customer customer = customerRepository
50 | .findById(id)
51 | .orElseThrow(() -> new BusinessServiceOperationException.CustomerNotFoundException("Customer not found"));
52 | if (customer.isDeleted()) {
53 | throw new BusinessServiceOperationException.CustomerAlreadyDeletedException("Customer already deleted");
54 | }
55 | if (hardDelete) {
56 | customerRepository.delete(customer);
57 | return;
58 | }
59 | customer.setDeleted(true);
60 | customerRepository.save(customer);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/validator/CreateCustomerRequestValidator.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.validator;
2 |
3 | import org.patikadev.orderexample.dto.CreateCustomerRequestDTO;
4 | import org.patikadev.orderexample.exception.BaseValidationException;
5 | import org.patikadev.orderexample.exception.ValidationOperationException;
6 | import org.springframework.stereotype.Component;
7 | import org.springframework.util.StringUtils;
8 |
9 | import java.util.Objects;
10 |
11 | @Component
12 | public class CreateCustomerRequestValidator implements Validator {
13 |
14 | @Override
15 | public void validate(CreateCustomerRequestDTO customerDTO) throws BaseValidationException {
16 | // fail first approach.
17 | if (Objects.isNull(customerDTO)) {
18 | throw new ValidationOperationException.CustomerNotValidException("Customer can not be null or empty");
19 | }
20 | if (!(StringUtils.hasLength(customerDTO.userName()))) {
21 | throw new ValidationOperationException.CustomerNotValidException("Customer username can not be null or empty");
22 | }
23 | if (!(StringUtils.hasLength(customerDTO.password()))) {
24 | throw new ValidationOperationException.CustomerNotValidException("Customer password can not be null or empty");
25 | }
26 | if (Objects.isNull(customerDTO.identity())) {
27 | throw new ValidationOperationException.CustomerNotValidException("Customer identity can not be null or empty");
28 | }
29 | if (Objects.isNull(customerDTO.gender())) {
30 | throw new ValidationOperationException.CustomerNotValidException("Customer gender can not be null or empty");
31 | }
32 | // customer address should validate
33 |
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/validator/CustomerIDValidator.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.validator;
2 |
3 | import org.patikadev.orderexample.exception.BaseValidationException;
4 | import org.patikadev.orderexample.exception.ValidationOperationException;
5 | import org.springframework.stereotype.Component;
6 |
7 | @Component
8 | public class CustomerIDValidator implements Validator {
9 | @Override
10 | public void validate(Long id) throws BaseValidationException {
11 | if (id < 0) {
12 | throw new ValidationOperationException.CustomerIDNotValidException("Customer ID should be greater than zero.");
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/order-example/src/main/java/org/patikadev/orderexample/validator/Validator.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample.validator;
2 |
3 | import org.patikadev.orderexample.exception.BaseValidationException;
4 |
5 | public interface Validator {
6 |
7 | void validate(T input) throws BaseValidationException;
8 | }
9 |
--------------------------------------------------------------------------------
/order-example/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8080
2 | spring.datasource.url=jdbc:h2:file:~/Users/solvia/mydb3
3 | spring.datasource.driverClassName=org.h2.Driver
4 | spring.datasource.username=sa
5 | spring.datasource.password=
6 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
7 | spring.jpa.hibernate.ddl-auto=create-drop
8 | spring.jpa.show-sql=true
9 | spring.h2.console.enabled=true
10 | spring.h2.console.path=/h2
--------------------------------------------------------------------------------
/order-example/src/test/java/org/patikadev/orderexample/OrderExampleApplicationTests.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.orderexample;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class OrderExampleApplicationTests {
8 |
9 |
10 | @Test
11 | void contextLoads() {
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/proxy-design-pattern/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/proxy-design-pattern/.idea/description.html:
--------------------------------------------------------------------------------
1 | Simple Java application that includes a class with main()
method
--------------------------------------------------------------------------------
/proxy-design-pattern/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/proxy-design-pattern/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/proxy-design-pattern/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/proxy-design-pattern/.idea/project-template.xml:
--------------------------------------------------------------------------------
1 |
2 | IJ_BASE_PACKAGE
3 |
--------------------------------------------------------------------------------
/proxy-design-pattern/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/proxy-design-pattern/.idea/sonarlint/issuestore/0/7/0718adcc89accfcfba0ef98c4c79cd538c12e17a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/proxy-design-pattern/.idea/sonarlint/issuestore/0/7/0718adcc89accfcfba0ef98c4c79cd538c12e17a
--------------------------------------------------------------------------------
/proxy-design-pattern/.idea/sonarlint/issuestore/3/5/357f0a3c0a04084e4cd5a471d68ecf6835c061e7:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/proxy-design-pattern/.idea/sonarlint/issuestore/3/5/357f0a3c0a04084e4cd5a471d68ecf6835c061e7
--------------------------------------------------------------------------------
/proxy-design-pattern/.idea/sonarlint/issuestore/e/8/e8b71cf26b4779249765a837676a7075ce95d804:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/proxy-design-pattern/.idea/sonarlint/issuestore/e/8/e8b71cf26b4779249765a837676a7075ce95d804
--------------------------------------------------------------------------------
/proxy-design-pattern/.idea/sonarlint/issuestore/f/9/f94f541ddc062375866943fa83c7ef9d2d232ade:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/proxy-design-pattern/.idea/sonarlint/issuestore/f/9/f94f541ddc062375866943fa83c7ef9d2d232ade
--------------------------------------------------------------------------------
/proxy-design-pattern/.idea/sonarlint/issuestore/index.pb:
--------------------------------------------------------------------------------
1 |
2 | O
3 | src/dev/patika/spring/Main.java,f/9/f94f541ddc062375866943fa83c7ef9d2d232ade
4 | X
5 | (src/dev/patika/spring/RealPresident.java,0/7/0718adcc89accfcfba0ef98c4c79cd538c12e17a
6 | Y
7 | )src/dev/patika/spring/ProxyPresident.java,e/8/e8b71cf26b4779249765a837676a7075ce95d804
8 | T
9 | $src/dev/patika/spring/President.java,3/5/357f0a3c0a04084e4cd5a471d68ecf6835c061e7
--------------------------------------------------------------------------------
/proxy-design-pattern/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/proxy-design-pattern/proxy-design-pattern.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/proxy-design-pattern/src/dev/patika/spring/Main.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring;
2 |
3 | public class Main {
4 |
5 | public static void main(String[] args) {
6 | // write your code here
7 |
8 | President president = new ProxyPresident();
9 | String message1 = president.readAndAnswerEnvelope("Please help us");
10 | String message2 = president.readAndAnswerEnvelope("This is confidential envelope, please help us!");
11 | president.signNewLaws();
12 |
13 | System.out.println("Message 1 = " + message1);
14 | System.out.println("Message 2 = " + message2);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/proxy-design-pattern/src/dev/patika/spring/President.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring;
2 |
3 | public interface President {
4 |
5 | String readAndAnswerEnvelope(String message);
6 |
7 | void signNewLaws();
8 |
9 | void assign();
10 | }
11 |
--------------------------------------------------------------------------------
/proxy-design-pattern/src/dev/patika/spring/ProxyPresident.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring;
2 |
3 | public class ProxyPresident implements President {
4 |
5 |
6 | private final RealPresident realPresident;
7 |
8 | public ProxyPresident() {
9 | realPresident = new RealPresident();
10 | }
11 |
12 | @Override
13 | public String readAndAnswerEnvelope(String message) {
14 | if (message.contains("confidential")) { // Buradaki condition'a gore..
15 | return realPresident.readAndAnswerEnvelope(message);
16 | }
17 | return "We'll do that";
18 | }
19 |
20 | @Override
21 | public void signNewLaws() {
22 | // conditions
23 | if (realPresident.isOnTrip()) {
24 | System.out.println("Laws signed by Proxy President");
25 | } else {
26 | realPresident.signNewLaws();
27 | }
28 |
29 | }
30 |
31 | @Override
32 | public void assign() {
33 | //conditions..
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/proxy-design-pattern/src/dev/patika/spring/RealPresident.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring;
2 |
3 | public class RealPresident implements President {
4 |
5 | private boolean isOnTrip = false;
6 |
7 | @Override
8 | public String readAndAnswerEnvelope(String message) {
9 | System.out.println("Message which send from citizen read by Real President");
10 | return "We'll do that";
11 | }
12 |
13 | @Override
14 | public void signNewLaws() {
15 | System.out.println("Signed by Real President");
16 | }
17 |
18 | @Override
19 | public void assign() {
20 | System.out.println("Assigned by Real President");
21 | }
22 |
23 | public boolean isOnTrip() {
24 | return isOnTrip;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/rest-service/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/rest-service/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/rest-service/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/rest-service/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/rest-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.6.6
9 |
10 |
11 | dev.patika
12 | rest-service
13 | 0.0.1-SNAPSHOT
14 | rest-service
15 | rest-service
16 |
17 |
18 | 17
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-web
25 |
26 |
27 |
28 | org.projectlombok
29 | lombok
30 | true
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-starter-validation
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | org.springframework.boot
50 | spring-boot-maven-plugin
51 |
52 |
53 |
54 | org.projectlombok
55 | lombok
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/rest-service/src/main/java/dev/patika/restservice/RestServiceApplication.java:
--------------------------------------------------------------------------------
1 | package dev.patika.restservice;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.context.ConfigurableApplicationContext;
6 |
7 | @SpringBootApplication
8 | public class RestServiceApplication {
9 |
10 | // Model -> Depo, Ürün, Employee
11 |
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(RestServiceApplication.class, args);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/rest-service/src/main/java/dev/patika/restservice/exceptions/PatikaDevBootcampControllerException.java:
--------------------------------------------------------------------------------
1 | package dev.patika.restservice.exceptions;
2 |
3 | public class PatikaDevBootcampControllerException extends Exception {
4 |
5 | public PatikaDevBootcampControllerException() {
6 | }
7 |
8 | public PatikaDevBootcampControllerException(String message) {
9 | super(message);
10 | }
11 |
12 | public PatikaDevBootcampControllerException(String message, Throwable cause) {
13 | super(message, cause);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/rest-service/src/main/java/dev/patika/restservice/exceptions/RequestParameterNotValidException.java:
--------------------------------------------------------------------------------
1 | package dev.patika.restservice.exceptions;
2 |
3 | public class RequestParameterNotValidException extends PatikaDevBootcampControllerException {
4 |
5 | public RequestParameterNotValidException() {
6 | super();
7 | }
8 |
9 | public RequestParameterNotValidException(String message) {
10 | super(message);
11 | }
12 |
13 | public RequestParameterNotValidException(String message, Throwable cause) {
14 | super(message, cause);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/rest-service/src/main/java/dev/patika/restservice/model/WarehouseModel.java:
--------------------------------------------------------------------------------
1 | package dev.patika.restservice.model;
2 |
3 | import lombok.Builder;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 |
7 | import javax.validation.constraints.Min;
8 | import javax.validation.constraints.NotBlank;
9 | import javax.validation.constraints.NotNull;
10 | import java.math.BigDecimal;
11 |
12 | @Getter
13 | @Setter
14 | @Builder(builderMethodName = "of")
15 | public class WarehouseModel {
16 |
17 | @NotBlank(message = "İsim alanı boş olamaz.")
18 | private String name;
19 | @NotNull(message = "Tipi alanı boş olamaz..")
20 | private WarehouseType type;
21 | private String address;
22 | @Min(value = 51, message = "Deponun yüz ölçümü 50'den küçük olamaz.")
23 | private BigDecimal area; // 50m2'den büyük olmak zorunda.
24 | private BigDecimal latitude;
25 | private BigDecimal longitude;
26 |
27 |
28 | public enum WarehouseType {
29 | HOT, COLD
30 | }
31 |
32 | @Override
33 | public String toString() {
34 | return "WarehouseModel{" +
35 | "name='" + name + '\'' +
36 | ", type=" + type +
37 | ", address='" + address + '\'' +
38 | ", area=" + area +
39 | ", latitude=" + latitude +
40 | ", longitude=" + longitude +
41 | '}';
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/rest-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=7089
2 |
--------------------------------------------------------------------------------
/rest-service/src/test/java/dev/patika/restservice/RestServiceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package dev.patika.restservice;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class RestServiceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/sp-core/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/sp-core/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/sp-core/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sp-core/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/sp-core/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/0/2/025c6d3ce74ff3a34ed2eb402dda4de27250535d:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/sp-core/.idea/sonarlint/issuestore/0/2/025c6d3ce74ff3a34ed2eb402dda4de27250535d
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/0/d/0d1c5e2749d82b75b31ee3add09b12949e82639a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/sp-core/.idea/sonarlint/issuestore/0/d/0d1c5e2749d82b75b31ee3add09b12949e82639a
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/2/a/2a7e6c061e93f42dace537cb3432475c46646428:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/sp-core/.idea/sonarlint/issuestore/2/a/2a7e6c061e93f42dace537cb3432475c46646428
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/2/e/2e82b65470137429f7a74217a23b82d4a9bfe968:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/sp-core/.idea/sonarlint/issuestore/2/e/2e82b65470137429f7a74217a23b82d4a9bfe968
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/4/4/442292b8a7efeabbe4cc176709b833b1792140ec:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/sp-core/.idea/sonarlint/issuestore/4/4/442292b8a7efeabbe4cc176709b833b1792140ec
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/5/0/50e22bb237393735bb14b2f347782d84243de526:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/sp-core/.idea/sonarlint/issuestore/5/0/50e22bb237393735bb14b2f347782d84243de526
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/6/d/6d1037c8686b1235851a981a79297dcaf0bb0917:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/sp-core/.idea/sonarlint/issuestore/6/d/6d1037c8686b1235851a981a79297dcaf0bb0917
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/7/2/72bfd8c707c7f2452e49dd10a9f972bc1ad0c08c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/sp-core/.idea/sonarlint/issuestore/7/2/72bfd8c707c7f2452e49dd10a9f972bc1ad0c08c
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/9/f/9fca2448ea657635e4fa1971e51353c45b49a64d:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/sp-core/.idea/sonarlint/issuestore/9/f/9fca2448ea657635e4fa1971e51353c45b49a64d
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/d/6/d6eef06968b700406a75043942e73224cb41fe6f:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/sp-core/.idea/sonarlint/issuestore/d/6/d6eef06968b700406a75043942e73224cb41fe6f
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/d/8/d8a7d6a75f2bb10f06cfbee5ab6644d47226f91a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/sp-core/.idea/sonarlint/issuestore/d/8/d8a7d6a75f2bb10f06cfbee5ab6644d47226f91a
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/d/b/db9f26078aa1bfe68bed16f23e7b4ad516668ed6:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/sp-core/.idea/sonarlint/issuestore/d/b/db9f26078aa1bfe68bed16f23e7b4ad516668ed6
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/f/5/f5ea8f01e9f11e11872ac10af80f68508519e299:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/sp-core/.idea/sonarlint/issuestore/f/5/f5ea8f01e9f11e11872ac10af80f68508519e299
--------------------------------------------------------------------------------
/sp-core/.idea/sonarlint/issuestore/index.pb:
--------------------------------------------------------------------------------
1 |
2 | d
3 | 4src/main/java/dev/patika/spring/model/OrderItem.java,0/d/0d1c5e2749d82b75b31ee3add09b12949e82639a
4 | b
5 | 2src/main/java/dev/patika/spring/model/Product.java,0/2/025c6d3ce74ff3a34ed2eb402dda4de27250535d
6 | o
7 | ?src/main/java/dev/patika/spring/service/ProductServiceImpl.java,6/d/6d1037c8686b1235851a981a79297dcaf0bb0917
8 | k
9 | ;src/main/java/dev/patika/spring/service/ProductService.java,d/8/d8a7d6a75f2bb10f06cfbee5ab6644d47226f91a
10 | i
11 | 9src/main/java/dev/patika/spring/service/OrderService.java,d/b/db9f26078aa1bfe68bed16f23e7b4ad516668ed6
12 | t
13 | Dsrc/main/java/dev/patika/spring/config/ApplicationConfiguration.java,2/e/2e82b65470137429f7a74217a23b82d4a9bfe968
14 | o
15 | ?src/main/java/dev/patika/spring/controller/OrderController.java,2/a/2a7e6c061e93f42dace537cb3432475c46646428
16 | `
17 | 0src/main/java/dev/patika/spring/model/Order.java,9/f/9fca2448ea657635e4fa1971e51353c45b49a64d
18 | l
19 |
2 |
5 | 4.0.0
6 |
7 | dev.patika
8 | spring
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 17
13 | 17
14 |
15 |
16 |
17 |
18 |
19 | org.springframework
20 | spring-context
21 | 5.3.18
22 |
23 |
24 | org.springframework
25 | spring-context-support
26 | 5.3.18
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/sp-core/src/main/java/dev/patika/spring/PatikaDevApplication.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring;
2 |
3 |
4 | import dev.patika.spring.controller.OrderController;
5 | import org.springframework.context.annotation.AnnotationConfigApplicationContext;
6 | import org.springframework.context.support.ClassPathXmlApplicationContext;
7 |
8 | public class PatikaDevApplication {
9 |
10 |
11 | public static void main(String[] args) {
12 | ClassPathXmlApplicationContext classPathXmlApplicationContext =
13 | new ClassPathXmlApplicationContext();
14 | classPathXmlApplicationContext.setConfigLocation("configuration.xml");
15 |
16 |
17 | AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext("dev.patika.spring");
18 | annotationConfigApplicationContext.setParent(classPathXmlApplicationContext);
19 |
20 | OrderController orderController = classPathXmlApplicationContext.getBean("orderController", OrderController.class);
21 | orderController.createOrder();
22 |
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/sp-core/src/main/java/dev/patika/spring/config/ApplicationConfiguration.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.config;
2 |
3 | import dev.patika.spring.service.CustomerService;
4 | import dev.patika.spring.service.CustomerServiceImpl;
5 | import dev.patika.spring.service.OrderService;
6 | import dev.patika.spring.service.ProductService;
7 | import org.springframework.beans.factory.BeanFactoryAware;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.context.annotation.Bean;
10 | import org.springframework.context.annotation.Configuration;
11 |
12 | @Configuration
13 | public class ApplicationConfiguration {
14 |
15 |
16 | private ProductService productService;
17 | private OrderService orderService;
18 |
19 |
20 | @Bean
21 | public CustomerService customerService() {
22 | return new CustomerServiceImpl(orderService, productService);
23 | }
24 |
25 |
26 | public void setProductService(@Autowired ProductService productService) {
27 | this.productService = productService;
28 | }
29 |
30 |
31 | public void setOrderService(@Autowired OrderService orderService) {
32 | this.orderService = orderService;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/sp-core/src/main/java/dev/patika/spring/controller/OrderController.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.controller;
2 |
3 | import dev.patika.spring.service.OrderService;
4 |
5 | public class OrderController {
6 |
7 | private final OrderService orderService;
8 |
9 | public OrderController(OrderService orderService) {
10 | this.orderService = orderService;
11 | }
12 |
13 | public void createOrder() {
14 | System.out.println(orderService.createOrder());
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/sp-core/src/main/java/dev/patika/spring/model/Order.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.model;
2 |
3 | import java.math.BigDecimal;
4 | import java.util.ArrayList;
5 | import java.util.Date;
6 | import java.util.List;
7 |
8 | public class Order {
9 |
10 | private Integer id;
11 | private Date orderedDate;
12 | private Date deliveryDate;
13 | private List items = new ArrayList<>();
14 |
15 |
16 | public Integer getId() {
17 | return id;
18 | }
19 |
20 | public void setId(Integer id) {
21 | this.id = id;
22 | }
23 |
24 | public Date getOrderedDate() {
25 | return orderedDate;
26 | }
27 |
28 | public void setOrderedDate(Date orderedDate) {
29 | this.orderedDate = orderedDate;
30 | }
31 |
32 | public Date getDeliveryDate() {
33 | return deliveryDate;
34 | }
35 |
36 | public void setDeliveryDate(Date deliveryDate) {
37 | this.deliveryDate = deliveryDate;
38 | }
39 |
40 | public BigDecimal getTotalPrice() {
41 | return items.stream()
42 | .map(OrderItem::getPrice)
43 | .reduce(BigDecimal.ZERO, BigDecimal::add);
44 | }
45 |
46 | public void addItem(OrderItem orderItem) {
47 | this.items.add(orderItem);
48 | }
49 |
50 | public void addItems(List items) {
51 | this.items.addAll(items);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/sp-core/src/main/java/dev/patika/spring/model/OrderItem.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.model;
2 |
3 | import java.math.BigDecimal;
4 |
5 | public class OrderItem {
6 |
7 | private Integer id;
8 | private Product product;
9 | private BigDecimal quantity;
10 |
11 |
12 | public Integer getId() {
13 | return id;
14 | }
15 |
16 | public void setId(Integer id) {
17 | this.id = id;
18 | }
19 |
20 | public Product getProduct() {
21 | return product;
22 | }
23 |
24 | public void setProduct(Product product) {
25 | this.product = product;
26 | }
27 |
28 | public BigDecimal getQuantity() {
29 | return quantity;
30 | }
31 |
32 | public void setQuantity(BigDecimal quantity) {
33 | this.quantity = quantity;
34 | }
35 |
36 | public BigDecimal getPrice() {
37 | // 300.00 TL x 2 = 600
38 | return product.getPrice().multiply(quantity);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/sp-core/src/main/java/dev/patika/spring/model/Product.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.model;
2 |
3 | import java.math.BigDecimal;
4 |
5 | public class Product {
6 |
7 | private Integer id;
8 | private String name;
9 | private BigDecimal price;
10 |
11 |
12 | public Integer getId() {
13 | return id;
14 | }
15 |
16 | public void setId(Integer id) {
17 | this.id = id;
18 | }
19 |
20 | public String getName() {
21 | return name;
22 | }
23 |
24 | public void setName(String name) {
25 | this.name = name;
26 | }
27 |
28 | public BigDecimal getPrice() {
29 | return price;
30 | }
31 |
32 | public void setPrice(BigDecimal price) {
33 | this.price = price;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/sp-core/src/main/java/dev/patika/spring/service/CustomerService.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.service;
2 |
3 | public interface CustomerService {
4 |
5 | void customOperation();
6 | }
7 |
--------------------------------------------------------------------------------
/sp-core/src/main/java/dev/patika/spring/service/CustomerServiceImpl.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.service;
2 |
3 | import org.springframework.stereotype.Service;
4 |
5 | @Service
6 | public class CustomerServiceImpl implements CustomerService {
7 |
8 | private final OrderService orderService;
9 | private final ProductService productService;
10 |
11 | public CustomerServiceImpl(OrderService orderService, ProductService productService) {
12 | this.orderService = orderService;
13 | this.productService = productService;
14 | }
15 |
16 | @Override
17 | public void customOperation() {
18 | }
19 |
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/sp-core/src/main/java/dev/patika/spring/service/OrderService.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.service;
2 |
3 | import java.util.UUID;
4 |
5 | public interface OrderService {
6 | UUID createOrder();
7 | }
8 |
--------------------------------------------------------------------------------
/sp-core/src/main/java/dev/patika/spring/service/OrderServiceImpl.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.service;
2 |
3 | import dev.patika.spring.model.Order;
4 | import dev.patika.spring.model.OrderItem;
5 |
6 | import java.math.BigDecimal;
7 | import java.util.Arrays;
8 | import java.util.Date;
9 | import java.util.UUID;
10 |
11 | public class OrderServiceImpl implements OrderService {
12 |
13 |
14 | private ProductService productService;
15 |
16 | @Override
17 | public UUID createOrder() {
18 |
19 | Order order = new Order();
20 | order.setId(1);
21 | order.setOrderedDate(new Date());
22 | order.setDeliveryDate(null);
23 |
24 | OrderItem computer = new OrderItem();
25 | computer.setProduct(productService.findByKey("C"));
26 | computer.setQuantity(BigDecimal.valueOf(3));
27 |
28 | OrderItem phone = new OrderItem();
29 | phone.setProduct(productService.findByKey("P"));
30 | phone.setQuantity(BigDecimal.ONE);
31 | order.addItems(Arrays.asList(computer, phone));
32 |
33 | // save order
34 | return UUID.randomUUID();
35 | }
36 |
37 | public ProductService getProductService() {
38 | return productService;
39 | }
40 |
41 | public void setProductService(ProductService productService) {
42 | this.productService = productService;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/sp-core/src/main/java/dev/patika/spring/service/ProductService.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.service;
2 |
3 | import dev.patika.spring.model.Product;
4 |
5 | public interface ProductService {
6 |
7 | Product findByKey(String key);
8 | }
9 |
--------------------------------------------------------------------------------
/sp-core/src/main/java/dev/patika/spring/service/ProductServiceImpl.java:
--------------------------------------------------------------------------------
1 | package dev.patika.spring.service;
2 |
3 | import dev.patika.spring.model.Product;
4 |
5 | import java.math.BigDecimal;
6 | import java.util.HashMap;
7 | import java.util.Map;
8 |
9 | public class ProductServiceImpl implements ProductService {
10 |
11 | private final Map products = new HashMap<>();
12 |
13 | //Method instance yaratildiktan sonra cagirilacak.
14 | public void onInit() {
15 | createProducts();
16 | }
17 |
18 | @Override
19 | public Product findByKey(String key) {
20 | return products.get(key);
21 | }
22 |
23 | private void createProducts() {
24 | Product p1 = new Product();
25 | p1.setId(1);
26 | p1.setName("Computer");
27 | p1.setPrice(BigDecimal.valueOf(10_000));
28 |
29 | Product p2 = new Product();
30 | p2.setId(2);
31 | p2.setName("Phone");
32 | p2.setPrice(BigDecimal.valueOf(1_000));
33 |
34 | products.put("C", p1);
35 | products.put("P", p2);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/sp-core/src/main/resources/configuration-2.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/sp-core/src/main/resources/configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/spring-boot/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/spring-boot/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/spring-boot/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/spring-boot/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/spring-boot/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.6.6
9 |
10 |
11 | dev.patika
12 | spring-boot
13 | 0.0.1-SNAPSHOT
14 | spring-boot
15 | spring-boot
16 |
17 | 17
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter
23 |
24 |
25 |
26 | org.projectlombok
27 | lombok
28 | true
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-starter-test
33 | test
34 |
35 |
36 |
37 |
38 | org.apache.commons
39 | commons-lang3
40 | 3.12.0
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | org.springframework.boot
49 | spring-boot-maven-plugin
50 |
51 |
52 |
53 | org.projectlombok
54 | lombok
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/spring-boot/src/main/java/dev/patika/springboot/Application.java:
--------------------------------------------------------------------------------
1 | package dev.patika.springboot;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 |
7 | @SpringBootApplication
8 | public class Application {
9 |
10 | public static void main(String[] args) {
11 | SpringApplication.run(Application.class, args);
12 |
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/spring-boot/src/main/java/dev/patika/springboot/BusinessService.java:
--------------------------------------------------------------------------------
1 | package dev.patika.springboot;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.boot.web.servlet.server.Encoding;
5 | import org.springframework.stereotype.Service;
6 |
7 | import javax.annotation.PostConstruct;
8 |
9 | @Service
10 | public class BusinessService {
11 |
12 |
13 | private final CustomController customController;
14 | private CustomService customService;
15 | private CustomRepository customRepository;
16 | private CustomComponent customComponent;
17 | private Encoding encoding;
18 |
19 |
20 | public BusinessService(CustomController customController) {
21 | this.customController = customController;
22 | }
23 |
24 | @PostConstruct
25 | public void onInit() {
26 | customController.printMyName("Baran");
27 | customService.printMyName("Hazal");
28 | customRepository.printMyName("Ahmet");
29 | customComponent.printMyName("CustomComponent");
30 | encoding.getCharset();
31 | }
32 |
33 | @Autowired
34 | public void setCustomService(CustomService customService) {
35 | this.customService = customService;
36 | }
37 |
38 | @Autowired
39 | public void setCustomRepository(CustomRepository customRepository) {
40 | this.customRepository = customRepository;
41 | }
42 |
43 | @Autowired
44 | public void setCustomComponent(CustomComponent customComponent) {
45 | this.customComponent = customComponent;
46 | }
47 |
48 | @Autowired
49 | public void setEncoding(Encoding encoding) {
50 | this.encoding = encoding;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/spring-boot/src/main/java/dev/patika/springboot/CustomComponent.java:
--------------------------------------------------------------------------------
1 | package dev.patika.springboot;
2 |
3 | public interface CustomComponent {
4 |
5 | void printMyName(String name);
6 | }
7 |
--------------------------------------------------------------------------------
/spring-boot/src/main/java/dev/patika/springboot/CustomComponentImpl.java:
--------------------------------------------------------------------------------
1 | package dev.patika.springboot;
2 |
3 | import lombok.extern.slf4j.Slf4j;
4 | import org.springframework.stereotype.Component;
5 |
6 | @Slf4j
7 | @Component
8 | public class CustomComponentImpl implements CustomComponent {
9 |
10 | @Override
11 | public void printMyName(String name) {
12 | log.info("My name is -> [{}]", name);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/spring-boot/src/main/java/dev/patika/springboot/CustomController.java:
--------------------------------------------------------------------------------
1 | package dev.patika.springboot;
2 |
3 | import lombok.extern.slf4j.Slf4j;
4 | import org.springframework.stereotype.Controller;
5 |
6 | import javax.annotation.PostConstruct;
7 | import javax.annotation.PreDestroy;
8 |
9 | @Controller
10 | @Slf4j
11 | public class CustomController {
12 |
13 | @PostConstruct
14 | public void init() {
15 | log.info("Custom Controller Implementation initialized.");
16 | }
17 |
18 | @PreDestroy
19 | public void onDestroy() {
20 | log.info("Custom Controller Implementation destroyed.");
21 | }
22 |
23 | public void printMyName(String name){
24 | log.info("My name is -> [{}]", name);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/spring-boot/src/main/java/dev/patika/springboot/CustomRepository.java:
--------------------------------------------------------------------------------
1 | package dev.patika.springboot;
2 |
3 | public interface CustomRepository {
4 |
5 | void printMyName(String name);
6 | }
7 |
--------------------------------------------------------------------------------
/spring-boot/src/main/java/dev/patika/springboot/CustomRepositoryImpl.java:
--------------------------------------------------------------------------------
1 | package dev.patika.springboot;
2 |
3 | import lombok.extern.slf4j.Slf4j;
4 | import org.springframework.stereotype.Repository;
5 |
6 | import javax.annotation.PostConstruct;
7 | import javax.annotation.PreDestroy;
8 |
9 | @Repository
10 | @Slf4j
11 | public class CustomRepositoryImpl implements CustomRepository {
12 |
13 | @PostConstruct
14 | public void init() {
15 | log.info("Custom Repository Implementation initialized.");
16 | }
17 |
18 |
19 | @PreDestroy
20 | public void onDestroy() {
21 | log.info("Custom Repository Implementation destroyed.");
22 | }
23 |
24 | @Override
25 | public void printMyName(String name) {
26 | log.info("My name is -> [{}]", name);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/spring-boot/src/main/java/dev/patika/springboot/CustomService.java:
--------------------------------------------------------------------------------
1 | package dev.patika.springboot;
2 |
3 |
4 | public interface CustomService {
5 |
6 | void printMyName(String name);
7 | }
8 |
--------------------------------------------------------------------------------
/spring-boot/src/main/java/dev/patika/springboot/CustomServiceImpl.java:
--------------------------------------------------------------------------------
1 | package dev.patika.springboot;
2 |
3 | import lombok.extern.slf4j.Slf4j;
4 | import org.springframework.stereotype.Service;
5 |
6 | import javax.annotation.PostConstruct;
7 | import javax.annotation.PreDestroy;
8 |
9 | @Service
10 | @Slf4j
11 | public class CustomServiceImpl implements CustomService {
12 |
13 | @PostConstruct
14 | public void init() {
15 | log.info("Custom Service Implementation initialized.");
16 | }
17 |
18 |
19 | @PreDestroy
20 | public void onDestroy() {
21 | log.info("Custom Service Implementation destroyed.");
22 | }
23 |
24 | @Override
25 | public void printMyName(String name) {
26 | log.info("My name is -> [{}]", name);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/spring-boot/src/main/java/dev/patika/springboot/MyConfiguration.java:
--------------------------------------------------------------------------------
1 | package dev.patika.springboot;
2 |
3 | import org.springframework.boot.web.servlet.server.Encoding;
4 | import org.springframework.context.annotation.Bean;
5 | import org.springframework.context.annotation.Configuration;
6 |
7 | @Configuration
8 | public class MyConfiguration {
9 |
10 | @Bean
11 | public Encoding encoding() {
12 | return new Encoding();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/spring-boot/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/spring-boot/src/test/java/dev/patika/springboot/ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package dev.patika.springboot;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class ApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/172-Norma-Java-Spring-Bootcamp/examples/21671f4796de9e8bdfc7b3d1a9794ddb63117fbd/spring-security-jwt-api/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/spring-security-jwt-api/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/SpringSecurityJwtApiApplication.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringSecurityJwtApiApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringSecurityJwtApiApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/config/InitializerConfig.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.config;
2 |
3 | import lombok.RequiredArgsConstructor;
4 | import org.patikadev.springsecurityjwtapi.entity.Customer;
5 | import org.patikadev.springsecurityjwtapi.entity.User;
6 | import org.patikadev.springsecurityjwtapi.helper.DataCreator;
7 | import org.patikadev.springsecurityjwtapi.repository.CustomerRepository;
8 | import org.patikadev.springsecurityjwtapi.repository.UserRepository;
9 | import org.springframework.context.annotation.Configuration;
10 |
11 | import javax.annotation.PostConstruct;
12 | import java.util.Collection;
13 |
14 | @Configuration
15 | @RequiredArgsConstructor
16 | public class InitializerConfig {
17 |
18 | private final UserRepository userRepository;
19 | private final CustomerRepository customerRepository;
20 |
21 |
22 | @PostConstruct
23 | public void onInit() {
24 | Collection users = DataCreator.createUsers();
25 | Collection customers = DataCreator.createCustomers();
26 | userRepository.saveAll(users);
27 | customerRepository.saveAll(customers);
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/controller/AuthenticationController.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.controller;
2 |
3 |
4 | import lombok.RequiredArgsConstructor;
5 | import org.patikadev.springsecurityjwtapi.helper.JWTHelper;
6 | import org.patikadev.springsecurityjwtapi.model.AuthenticationRequest;
7 | import org.patikadev.springsecurityjwtapi.model.AuthenticationResponse;
8 | import org.patikadev.springsecurityjwtapi.security.UserDetail;
9 | import org.patikadev.springsecurityjwtapi.validator.AuthenticationRequestValidator;
10 | import org.springframework.http.ResponseEntity;
11 | import org.springframework.security.authentication.AuthenticationManager;
12 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
13 | import org.springframework.security.core.Authentication;
14 | import org.springframework.security.core.GrantedAuthority;
15 | import org.springframework.security.core.context.SecurityContextHolder;
16 | import org.springframework.web.bind.annotation.PostMapping;
17 | import org.springframework.web.bind.annotation.RequestBody;
18 | import org.springframework.web.bind.annotation.RequestMapping;
19 | import org.springframework.web.bind.annotation.RestController;
20 |
21 | import java.util.stream.Collectors;
22 |
23 | @RestController
24 | @RequestMapping("/api")
25 | @RequiredArgsConstructor
26 | public class AuthenticationController {
27 |
28 | private final AuthenticationRequestValidator authenticationRequestValidator
29 | = new AuthenticationRequestValidator();
30 |
31 | private final AuthenticationManager authenticationManager;
32 | private final JWTHelper jwtHelper;
33 |
34 | @PostMapping(path = "/sign-in")
35 | public ResponseEntity> signIn(@RequestBody AuthenticationRequest authenticationRequest) {
36 | authenticationRequestValidator.validate(authenticationRequest);
37 | Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(authenticationRequest.getUsername(), authenticationRequest.getPassword()));
38 | SecurityContextHolder.getContext().setAuthentication(authentication);
39 | UserDetail userDetail = (UserDetail) authentication.getPrincipal();
40 | String token = jwtHelper.generate(authenticationRequest.getUsername());
41 | return ResponseEntity.ok(new AuthenticationResponse(token,
42 | userDetail
43 | .getAuthorities()
44 | .stream()
45 | .map(GrantedAuthority::getAuthority)
46 | .collect(Collectors.toSet())));
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/controller/CustomerController.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.controller;
2 |
3 | import lombok.RequiredArgsConstructor;
4 | import org.patikadev.springsecurityjwtapi.repository.CustomerRepository;
5 | import org.springframework.http.ResponseEntity;
6 | import org.springframework.web.bind.annotation.GetMapping;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | @RestController
11 | @RequestMapping("/api/customer")
12 | @RequiredArgsConstructor
13 | public class CustomerController {
14 |
15 | private final CustomerRepository customerRepository;
16 |
17 |
18 | @GetMapping
19 | public ResponseEntity> getCustomers() {
20 | return ResponseEntity.ok(customerRepository.findAll());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/entity/Customer.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.entity;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 |
6 | import javax.persistence.Entity;
7 | import javax.persistence.GeneratedValue;
8 | import javax.persistence.GenerationType;
9 | import javax.persistence.Id;
10 |
11 | @Entity
12 | @Getter
13 | @Setter
14 | public class Customer {
15 |
16 | @Id
17 | @GeneratedValue(strategy = GenerationType.AUTO)
18 | private Long id;
19 |
20 | private String name;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/entity/Role.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.entity;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 |
6 | import javax.persistence.*;
7 |
8 | @Entity
9 | @Getter
10 | @Setter
11 | public class Role {
12 | @Id
13 | @GeneratedValue(strategy = GenerationType.AUTO)
14 | private Long id;
15 |
16 | private String name;
17 |
18 | @ManyToOne
19 | private User user;
20 |
21 | }
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/entity/User.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.entity;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 | import org.patikadev.springsecurityjwtapi.entity.enums.UserStatus;
6 |
7 | import javax.persistence.*;
8 | import java.util.Date;
9 | import java.util.HashSet;
10 | import java.util.Set;
11 |
12 |
13 | @Entity
14 | @Getter
15 | @Setter
16 | @Table
17 | public class User {
18 |
19 | @Id
20 | @GeneratedValue(strategy = GenerationType.AUTO)
21 | private Long id;
22 |
23 | @Column(unique = true)
24 | private String username;
25 | private String password;
26 |
27 | @Enumerated(EnumType.STRING)
28 | private UserStatus userStatus = UserStatus.ACTIVE;
29 |
30 | @Temporal(value = TemporalType.TIMESTAMP)
31 | private Date lastSuccessfullyLoggedInTime;
32 |
33 | @Temporal(value = TemporalType.TIMESTAMP)
34 | private Date lastFailureLoggedInTime;
35 |
36 | @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
37 | @JoinTable(name = "user_role",
38 | joinColumns = @JoinColumn(name = "user_id"),
39 | inverseJoinColumns = @JoinColumn(name = "role_id"))
40 | private Set roles = new HashSet<>();
41 |
42 |
43 | public void addRoles(Set roles) {
44 | roles.forEach(role -> role.setUser(this));
45 | this.roles.addAll(roles);
46 | }
47 |
48 | public void removeRoles(Set roles) {
49 | roles.forEach(role -> role.setUser(null));
50 | this.roles.removeAll(roles);
51 | }
52 |
53 | public void lockUser() {
54 | this.userStatus = UserStatus.LOCKED;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/entity/enums/UserStatus.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.entity.enums;
2 |
3 | public enum UserStatus {
4 |
5 | ACTIVE,
6 | LOCKED
7 | }
8 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/filter/JWTAuthenticationFilter.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.filter;
2 |
3 | import lombok.RequiredArgsConstructor;
4 | import org.apache.logging.log4j.util.Strings;
5 | import org.patikadev.springsecurityjwtapi.helper.JWTHelper;
6 | import org.patikadev.springsecurityjwtapi.security.UserDetailService;
7 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
8 | import org.springframework.security.core.context.SecurityContextHolder;
9 | import org.springframework.security.core.userdetails.UserDetails;
10 | import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
11 | import org.springframework.stereotype.Component;
12 | import org.springframework.util.StringUtils;
13 | import org.springframework.web.filter.OncePerRequestFilter;
14 |
15 | import javax.servlet.FilterChain;
16 | import javax.servlet.ServletException;
17 | import javax.servlet.http.HttpServletRequest;
18 | import javax.servlet.http.HttpServletResponse;
19 | import java.io.IOException;
20 |
21 | @Component
22 | @RequiredArgsConstructor
23 | public class JWTAuthenticationFilter extends OncePerRequestFilter {
24 |
25 | private final JWTHelper jwtHelper;
26 | private final UserDetailService userDetailService;
27 |
28 | @Override
29 | protected void doFilterInternal(HttpServletRequest request,
30 | HttpServletResponse response,
31 | FilterChain filterChain) throws ServletException, IOException {
32 |
33 | try {
34 | String jwt = findToken(request);
35 | if (StringUtils.hasLength(jwt) && jwtHelper.validate(jwt)) {
36 | String username = jwtHelper.findUsername(jwt);
37 | UserDetails userDetails = userDetailService.loadUserByUsername(username);
38 | UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(
39 | userDetails, null, userDetails.getAuthorities());
40 | authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
41 | SecurityContextHolder.getContext().setAuthentication(authentication);
42 | }
43 | } catch (Exception e) {
44 | logger.error("Cannot set user authentication: {}", e);
45 | }
46 | filterChain.doFilter(request, response);
47 | }
48 |
49 |
50 | private String findToken(HttpServletRequest request) {
51 | String headerAuth = request.getHeader("Authorization");
52 | if (StringUtils.hasText(headerAuth) && headerAuth.startsWith("Bearer ")) {
53 | return headerAuth.substring(7);
54 | }
55 | return Strings.EMPTY;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/helper/DataCreator.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.helper;
2 |
3 | import org.patikadev.springsecurityjwtapi.entity.Customer;
4 | import org.patikadev.springsecurityjwtapi.entity.Role;
5 | import org.patikadev.springsecurityjwtapi.entity.User;
6 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
7 |
8 | import java.util.Arrays;
9 | import java.util.Collection;
10 | import java.util.Collections;
11 |
12 | public final class DataCreator {
13 |
14 |
15 | private DataCreator() {
16 | throw new UnsupportedOperationException();
17 | }
18 |
19 | public static Collection createUsers() {
20 | BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
21 | User user = new User();
22 | user.setUsername("baran");
23 | user.setPassword(passwordEncoder.encode("password"));
24 | Role adminRole = new Role();
25 | adminRole.setName("ROLE_ADMIN");
26 | user.addRoles(Collections.singleton(adminRole));
27 | return Collections.singletonList(user);
28 | }
29 |
30 | public static Collection createCustomers() {
31 | Customer customer = new Customer();
32 | customer.setName("Google");
33 | Customer customer1 = new Customer();
34 | customer.setName("Microsoft");
35 | return Arrays.asList(customer1, customer);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/helper/JWTHelper.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.helper;
2 |
3 | import com.auth0.jwt.JWT;
4 | import com.auth0.jwt.algorithms.Algorithm;
5 | import com.auth0.jwt.exceptions.AlgorithmMismatchException;
6 | import com.auth0.jwt.exceptions.InvalidClaimException;
7 | import com.auth0.jwt.exceptions.SignatureVerificationException;
8 | import com.auth0.jwt.exceptions.TokenExpiredException;
9 | import lombok.Getter;
10 | import lombok.Setter;
11 | import lombok.extern.slf4j.Slf4j;
12 | import org.springframework.beans.factory.annotation.Value;
13 | import org.springframework.stereotype.Component;
14 | import org.springframework.util.StringUtils;
15 |
16 | import java.time.Instant;
17 | import java.util.Date;
18 |
19 | @Component
20 | @Getter
21 | @Setter
22 | @Slf4j
23 | public class JWTHelper {
24 |
25 | @Value("${ssja.jwt.secret-key}")
26 | private String secretKey;
27 | @Value("${ssja.jwt.expires-in}")
28 | private long expiresIn;
29 |
30 | public String generate(String username) {
31 | if (!StringUtils.hasLength(username)) {
32 | throw new IllegalArgumentException("Username can not be null or empty");
33 | }
34 | return JWT.create()
35 | .withIssuedAt(new Date())
36 | .withExpiresAt(new Date(Date.from(Instant.now()).getTime() + expiresIn))
37 | .withClaim("username", username)
38 | .sign(Algorithm.HMAC512(secretKey));
39 | }
40 |
41 | public String findUsername(String token) {
42 | if (!StringUtils.hasLength(token)) {
43 | throw new IllegalArgumentException("Token can not be null or empty");
44 | }
45 | return JWT.decode(token).getClaim("username").asString();
46 | }
47 |
48 | public boolean validate(String token) {
49 | try {
50 | JWT.require(Algorithm.HMAC512(secretKey))
51 | .build()
52 | .verify(token);
53 | return true;
54 | } catch (AlgorithmMismatchException algorithmMismatchException) {
55 | log.error("JWT Token AlgorithmMismatchException occurred!");
56 | } catch (SignatureVerificationException signatureVerificationException) {
57 | log.error("JWT Token SignatureVerificationException occurred!");
58 | } catch (TokenExpiredException tokenExpiredException) {
59 | log.error("JWT Token TokenExpiredException occurred!");
60 | } catch (InvalidClaimException invalidClaimException) {
61 | log.error("JWT Token InvalidClaimException occurred!");
62 | }
63 | return false;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/model/AuthenticationRequest.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.model;
2 |
3 |
4 | import lombok.Getter;
5 | import lombok.Setter;
6 |
7 | @Getter
8 | @Setter
9 | public class AuthenticationRequest {
10 |
11 | private String username;
12 | private String password;
13 | }
14 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/model/AuthenticationResponse.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.model;
2 |
3 | import java.util.Set;
4 |
5 |
6 | public record AuthenticationResponse(String token, Set roles) {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/repository/CustomerRepository.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.repository;
2 |
3 | import org.patikadev.springsecurityjwtapi.entity.Customer;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | public interface CustomerRepository extends JpaRepository {
7 | }
8 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/repository/UserRepository.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.repository;
2 |
3 | import org.patikadev.springsecurityjwtapi.entity.User;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | import java.util.Optional;
7 |
8 | public interface UserRepository extends JpaRepository {
9 |
10 | Optional findByUsername(String username);
11 | }
12 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/security/JWTAuthenticationEntryPoint.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.security;
2 |
3 | import lombok.extern.slf4j.Slf4j;
4 | import org.springframework.security.core.AuthenticationException;
5 | import org.springframework.security.web.AuthenticationEntryPoint;
6 | import org.springframework.stereotype.Component;
7 |
8 | import javax.servlet.ServletException;
9 | import javax.servlet.http.HttpServletRequest;
10 | import javax.servlet.http.HttpServletResponse;
11 | import java.io.IOException;
12 |
13 | @Component
14 | @Slf4j
15 | public class JWTAuthenticationEntryPoint implements AuthenticationEntryPoint {
16 | @Override
17 | public void commence(HttpServletRequest request,
18 | HttpServletResponse response,
19 | AuthenticationException authException) throws IOException, ServletException {
20 | log.error("Unauthorized {}", authException.getMessage());
21 | response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/security/UserDetail.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.security;
2 |
3 | import lombok.RequiredArgsConstructor;
4 | import org.patikadev.springsecurityjwtapi.entity.Role;
5 | import org.patikadev.springsecurityjwtapi.entity.enums.UserStatus;
6 | import org.springframework.security.core.GrantedAuthority;
7 | import org.springframework.security.core.authority.SimpleGrantedAuthority;
8 | import org.springframework.security.core.userdetails.UserDetails;
9 |
10 | import java.util.Collection;
11 | import java.util.Set;
12 |
13 |
14 | @RequiredArgsConstructor
15 | public class UserDetail implements UserDetails {
16 |
17 | private final String username;
18 | private final String password;
19 | private final Set roles;
20 | private final UserStatus userStatus;
21 |
22 |
23 | @Override
24 | public Collection extends GrantedAuthority> getAuthorities() {
25 | return roles.stream().map(role -> new SimpleGrantedAuthority(role.getName())).toList();
26 | }
27 |
28 | @Override
29 | public String getPassword() {
30 | return password;
31 | }
32 |
33 | @Override
34 | public String getUsername() {
35 | return username;
36 | }
37 |
38 | @Override
39 | public boolean isAccountNonExpired() {
40 | return true;
41 | }
42 |
43 | @Override
44 | public boolean isAccountNonLocked() {
45 | return !(userStatus.equals(UserStatus.LOCKED));
46 | }
47 |
48 | @Override
49 | public boolean isCredentialsNonExpired() {
50 | return true;
51 | }
52 |
53 | @Override
54 | public boolean isEnabled() {
55 | return userStatus.equals(UserStatus.ACTIVE);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/security/UserDetailService.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.security;
2 |
3 | import lombok.RequiredArgsConstructor;
4 | import org.patikadev.springsecurityjwtapi.entity.User;
5 | import org.patikadev.springsecurityjwtapi.repository.UserRepository;
6 | import org.springframework.security.core.userdetails.UserDetails;
7 | import org.springframework.security.core.userdetails.UserDetailsService;
8 | import org.springframework.security.core.userdetails.UsernameNotFoundException;
9 | import org.springframework.stereotype.Service;
10 |
11 | @Service
12 | @RequiredArgsConstructor
13 | public class UserDetailService implements UserDetailsService {
14 |
15 | private final UserRepository userRepository;
16 |
17 | @Override
18 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
19 | User user = userRepository.findByUsername(username).orElseThrow(() -> new UsernameNotFoundException(username + " not found"));
20 | return new UserDetail(user.getUsername(), user.getPassword(), user.getRoles(), user.getUserStatus());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/java/org/patikadev/springsecurityjwtapi/validator/AuthenticationRequestValidator.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi.validator;
2 |
3 |
4 | import org.patikadev.springsecurityjwtapi.model.AuthenticationRequest;
5 | import org.springframework.util.StringUtils;
6 |
7 | import java.util.Objects;
8 |
9 | public class AuthenticationRequestValidator {
10 |
11 | public void validate(AuthenticationRequest authenticationRequest) {
12 | if (Objects.isNull(authenticationRequest)) {
13 | throw new IllegalArgumentException("AuthenticationRequest can't be null");
14 | }
15 | if (!(StringUtils.hasLength(authenticationRequest.getUsername()))) {
16 | throw new IllegalArgumentException("Username can't be null");
17 | }
18 | if (!(StringUtils.hasLength(authenticationRequest.getPassword()))) {
19 | throw new IllegalArgumentException("Password¬ can't be null");
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8080
2 | spring.datasource.url=jdbc:h2:mem:ssja
3 | spring.datasource.driverClassName=org.h2.Driver
4 | spring.datasource.username=sa
5 | spring.datasource.password=
6 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
7 | spring.jpa.hibernate.ddl-auto=create-drop
8 | spring.jpa.show-sql=true
9 | spring.h2.console.enabled=true
10 | spring.h2.console.path=/h2
11 |
12 | ssja.jwt.secret-key=ue2@`<@FKA{gDy]!P(2-e5rS1BryFe
13 | ssja.jwt.expires-in=1800000
--------------------------------------------------------------------------------
/spring-security-jwt-api/src/test/java/org/patikadev/springsecurityjwtapi/BcryptPasswordEncoderTest.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurityjwtapi;
2 |
3 | import org.assertj.core.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
7 |
8 | @SpringBootTest
9 | public class BcryptPasswordEncoderTest {
10 |
11 | private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
12 |
13 |
14 | @Test
15 | void should_match_password_with_bcryptPasswordEncoder() {
16 | String password = "password";
17 | String encodedPassword = passwordEncoder.encode(password);
18 | Assertions.assertThat(encodedPassword).isNotEmpty();
19 | Assertions.assertThat(passwordEncoder.matches(password, encodedPassword)).isTrue();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/spring-security/src/main/java/org/patikadev/springsecurity/configuration/CustomConfiguration.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurity;
2 |
3 |
4 | import org.springframework.context.annotation.Bean;
5 | import org.springframework.context.annotation.Configuration;
6 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
7 | import org.springframework.security.crypto.password.PasswordEncoder;
8 |
9 | @Configuration
10 | public class CustomConfiguration {
11 |
12 | @Bean
13 | public PasswordEncoder passwordEncoder(){
14 | return new BCryptPasswordEncoder();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/spring-security/src/main/java/org/patikadev/springsecurity/configuration/SecurityConfiguration.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurity.configuration;public class SecurityConfiguration {
2 | }
3 |
--------------------------------------------------------------------------------
/spring-security/src/main/java/org/patikadev/springsecurity/entities/MyUser.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurity.entity;
2 |
3 |
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | import javax.persistence.Entity;
9 | import javax.persistence.GeneratedValue;
10 | import javax.persistence.GenerationType;
11 | import javax.persistence.Id;
12 |
13 | @Entity
14 | @Getter
15 | @Setter
16 | @NoArgsConstructor
17 | public class User {
18 |
19 | @Id
20 | @GeneratedValue(strategy = GenerationType.IDENTITY)
21 | private Integer id;
22 |
23 | private String username;
24 | private String password;
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/spring-security/src/main/java/org/patikadev/springsecurity/repository/LoggedUser.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurity.repository;public class LoggedUser {
2 | }
3 |
--------------------------------------------------------------------------------
/spring-security/src/main/java/org/patikadev/springsecurity/repository/UserRepository.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurity;
2 |
3 | public class UserRepository {
4 | }
5 |
--------------------------------------------------------------------------------
/spring-security/src/main/java/org/patikadev/springsecurity/security/H2DatabaseUserDetailService.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurity;
2 |
3 | import org.springframework.security.core.userdetails.UserDetails;
4 | import org.springframework.security.core.userdetails.UserDetailsService;
5 | import org.springframework.security.core.userdetails.UsernameNotFoundException;
6 |
7 |
8 | public class H2DatabaseUserDetailService implements UserDetailsService {
9 |
10 |
11 | @Override
12 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
13 | return null;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/spring-security/src/main/java/org/patikadev/springsecurity/service/UserService.java:
--------------------------------------------------------------------------------
1 | package org.patikadev.springsecurity.configuration;
2 |
3 | import lombok.RequiredArgsConstructor;
4 | import org.patikadev.springsecurity.entities.MyUser;
5 | import org.patikadev.springsecurity.repository.UserRepository;
6 | import org.springframework.security.crypto.password.PasswordEncoder;
7 | import org.springframework.stereotype.Component;
8 |
9 | import javax.annotation.PostConstruct;
10 |
11 | @Component
12 | @RequiredArgsConstructor
13 | public class UserCreateService {
14 |
15 | private final UserRepository userRepository;
16 | private final PasswordEncoder passwordEncoder;
17 |
18 | @PostConstruct
19 | public void onInit() {
20 | MyUser user = new MyUser();
21 | user.setPassword(passwordEncoder.encode("password"));
22 | user.setUsername("BaranBuyuk");
23 | userRepository.save(user);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------