├── .gitignore ├── apache-httpclient └── src │ └── main │ └── resources │ └── notes │ └── todo.txt ├── spring-mvc-1 ├── src │ ├── main │ │ ├── resources │ │ │ ├── templates │ │ │ │ ├── welcome.html │ │ │ │ ├── templatelocation │ │ │ │ │ ├── hi.html │ │ │ │ │ ├── other │ │ │ │ │ │ └── bye.html │ │ │ │ │ └── another │ │ │ │ │ │ └── farewell.html │ │ │ │ ├── suffixmatch │ │ │ │ │ └── hello.html │ │ │ │ ├── model │ │ │ │ │ └── greet.html │ │ │ │ └── introduction │ │ │ │ │ ├── homepage.html │ │ │ │ │ └── comment.html │ │ │ ├── application.properties │ │ │ ├── application-requestmapping.properties │ │ │ ├── application-mdc.properties │ │ │ ├── application-serverproperties.properties │ │ │ └── application-jacksonconfigure.properties │ │ └── java │ │ │ └── com │ │ │ └── javabyexamples │ │ │ └── spring │ │ │ └── mvc1 │ │ │ ├── restwithjson │ │ │ ├── view │ │ │ │ ├── PrivateDetails.java │ │ │ │ ├── PublicDetails.java │ │ │ │ └── Customer.java │ │ │ ├── Query.java │ │ │ ├── Customer.java │ │ │ └── Application.java │ │ │ ├── model │ │ │ └── Greeting.java │ │ │ ├── currentrequest │ │ │ ├── Person.java │ │ │ └── Application.java │ │ │ ├── jacksonconfiguration │ │ │ ├── Query.java │ │ │ ├── SearchResult.java │ │ │ ├── explicit │ │ │ │ └── Application.java │ │ │ ├── customizer │ │ │ │ └── Application.java │ │ │ └── properties │ │ │ │ └── Application.java │ │ │ ├── controller │ │ │ └── Message.java │ │ │ ├── restwithxml │ │ │ ├── castor │ │ │ │ ├── PersonCriteria.java │ │ │ │ ├── PersonDetails.java │ │ │ │ └── Application.java │ │ │ ├── xstream │ │ │ │ ├── PersonCriteria.java │ │ │ │ ├── PersonDetails.java │ │ │ │ └── Application.java │ │ │ ├── jaxb │ │ │ │ └── Application.java │ │ │ └── builtin │ │ │ │ └── Application.java │ │ │ ├── requestresponsebodyadvice │ │ │ ├── Answer.java │ │ │ ├── Question.java │ │ │ └── Application.java │ │ │ ├── requestresponsebody │ │ │ ├── PersonWithoutXMLAnnotation.java │ │ │ ├── Person.java │ │ │ └── Application.java │ │ │ ├── mdc │ │ │ ├── filter │ │ │ │ └── HelloService.java │ │ │ └── interceptor │ │ │ │ ├── HelloService.java │ │ │ │ └── Application.java │ │ │ ├── suffixmatch │ │ │ ├── SuffixMatchController.java │ │ │ ├── SuffixMatchRestController.java │ │ │ └── api │ │ │ │ └── HealthRestController.java │ │ │ ├── async │ │ │ └── Application.java │ │ │ ├── headers │ │ │ └── Application.java │ │ │ ├── interceptor │ │ │ ├── Application.java │ │ │ ├── HelloController.java │ │ │ └── ApiController.java │ │ │ ├── responsestatus │ │ │ └── Application.java │ │ │ ├── asyncinterceptor │ │ │ └── Application.java │ │ │ ├── requestmapping │ │ │ ├── paths │ │ │ │ └── Exam.java │ │ │ └── Application.java │ │ │ ├── restreturnvalues │ │ │ └── Application.java │ │ │ ├── shortcutmapping │ │ │ └── Application.java │ │ │ ├── templatelocation │ │ │ └── Application.java │ │ │ ├── callableinterceptor │ │ │ └── Application.java │ │ │ ├── deferredinterceptor │ │ │ └── Application.java │ │ │ └── serverconfiguration │ │ │ ├── properties │ │ │ ├── PingController.java │ │ │ └── Application.java │ │ │ └── tomcat │ │ │ ├── customizer │ │ │ ├── PingController.java │ │ │ └── Application.java │ │ │ └── factorycustomizer │ │ │ ├── PingController.java │ │ │ └── Application.java │ └── test │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── spring │ │ └── mvc1 │ │ └── controller │ │ └── ApplicationTest.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties └── .gitignore ├── maven-and-plugins ├── modules │ └── module1 │ │ └── src │ │ └── main │ │ └── resources │ │ └── db.properties ├── .gitignore ├── README.md ├── failsafe │ └── src │ │ ├── test │ │ ├── resources │ │ │ ├── sample.properties │ │ │ ├── includes.txt │ │ │ └── excludes.txt │ │ └── java │ │ │ └── com │ │ │ └── javabyexamples │ │ │ └── maven │ │ │ └── plugins │ │ │ └── failsafe │ │ │ ├── groups │ │ │ ├── FastTest.java │ │ │ ├── SlowTest.java │ │ │ └── Person2IT.java │ │ │ └── SampleIT.java │ │ └── main │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── maven │ │ └── plugins │ │ └── failsafe │ │ └── Person.java ├── surefire │ └── src │ │ ├── test │ │ ├── resources │ │ │ ├── sample.properties │ │ │ ├── excludes.txt │ │ │ ├── includes.txt │ │ │ └── debug-commands.txt │ │ └── java │ │ │ └── com │ │ │ └── javabyexamples │ │ │ └── maven │ │ │ └── plugins │ │ │ └── surefire │ │ │ ├── groups │ │ │ ├── FastTest.java │ │ │ ├── SlowTest.java │ │ │ └── RegularPersonTest.java │ │ │ ├── SampleE2E.java │ │ │ ├── E2ETestCase1.java │ │ │ ├── SampleTestCase1.java │ │ │ └── SampleTest.java │ │ └── main │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── maven │ │ └── plugins │ │ └── surefire │ │ └── Person.java ├── buildhelper │ ├── imported │ │ ├── main │ │ │ ├── resources │ │ │ │ └── imported.properties │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── javabyexamples │ │ │ │ └── maven │ │ │ │ └── plugins │ │ │ │ └── buildhelper │ │ │ │ └── Job.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── isa │ │ │ └── maven │ │ │ └── plugins │ │ │ └── buildhelper │ │ │ └── JobTest.java │ └── src │ │ └── main │ │ └── resources │ │ └── my.properties ├── resource │ ├── additional-resources │ │ ├── extraResource.txt │ │ └── anotherExtraResource.txt │ ├── other-resources │ │ ├── environment │ │ │ ├── int │ │ │ │ └── intResource.txt │ │ │ └── prod │ │ │ │ └── prodResource.txt │ │ └── filtering │ │ │ └── myFilter.properties │ └── src │ │ ├── main │ │ └── resources │ │ │ └── app.properties │ │ └── test │ │ └── resources │ │ └── appTest.properties ├── property │ └── src │ │ ├── main │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── maven │ │ └── plugins │ │ └── property │ │ └── SetPropertyTest.java └── compile │ └── src │ └── main │ └── java │ └── com │ └── javabyexamples │ └── maven │ └── plugins │ └── compiler │ └── Main.java ├── spring-core-3 ├── src │ ├── main │ │ ├── resources │ │ │ ├── resource │ │ │ │ └── rules.txt │ │ │ ├── fileasresource │ │ │ │ └── hello.txt │ │ │ └── propertysource │ │ │ │ └── sample.properties │ │ └── java │ │ │ └── com │ │ │ └── javabyexamples │ │ │ └── spring │ │ │ └── core │ │ │ ├── resource │ │ │ └── package-info.java │ │ │ ├── spel │ │ │ ├── basic │ │ │ │ └── package-info.java │ │ │ └── beanusage │ │ │ │ └── RandomService.java │ │ │ └── propertysource │ │ │ ├── placeholder │ │ │ └── package-info.java │ │ │ └── useannotation │ │ │ └── PropertySourceConfiguration.java │ └── test │ │ ├── resources │ │ └── resource │ │ │ └── test-rules.txt │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── spring │ │ └── core │ │ └── spel │ │ ├── basic │ │ ├── Person.java │ │ └── Address.java │ │ └── rootobject │ │ ├── Address.java │ │ └── Person.java └── README.md ├── README.md ├── java-and-tools ├── README.md └── lombok │ └── src │ └── main │ ├── resources │ └── log4j.properties │ └── java │ └── com │ └── javabyexamples │ └── java │ └── tools │ └── lombok │ └── annotations │ ├── data │ ├── Employee.java │ ├── staticconstructor │ │ └── Employee.java │ └── EmployeeExpanded.java │ ├── value │ ├── Employee.java │ ├── staticconstructor │ │ └── Employee.java │ └── accessmodifier │ │ └── Employee.java │ ├── tostring │ ├── inheritance │ │ ├── Person.java │ │ └── Developer.java │ ├── basic │ │ ├── Developer.java │ │ └── DeveloperDelomboked.java │ ├── fieldname │ │ └── Developer.java │ ├── exclude │ │ ├── classlevel │ │ │ ├── Developer.java │ │ │ └── DeveloperDelomboked.java │ │ └── fieldlevel │ │ │ ├── Developer.java │ │ │ └── DeveloperDelomboked.java │ ├── recursion │ │ ├── Manager.java │ │ ├── Developer.java │ │ └── RecursionTest.java │ └── include │ │ ├── classlevel │ │ └── Developer.java │ │ ├── fieldlevel │ │ └── Developer.java │ │ └── methodlevel │ │ └── Developer.java │ ├── setter │ ├── Account.java │ └── AccountDelomboked.java │ ├── builder │ ├── classlevel │ │ └── Student.java │ ├── defaultvalue │ │ └── Student.java │ ├── singular │ │ └── Student.java │ └── constructorlevel │ │ └── Student.java │ ├── constructors │ ├── allargs │ │ ├── parent │ │ │ ├── Citizen.java │ │ │ └── Employee.java │ │ └── Employee.java │ ├── noargs │ │ ├── EmployeeDelomboked.java │ │ └── Employee.java │ └── requiredargs │ │ ├── EmployeeDelomboked.java │ │ └── Employee.java │ ├── equalsandhashcode │ ├── inheritance │ │ ├── Citizen.java │ │ └── Employee.java │ ├── basic │ │ └── Employee.java │ ├── include │ │ ├── classlevel │ │ │ └── Employee.java │ │ ├── fieldlevel │ │ │ └── Employee.java │ │ └── methodlevel │ │ │ └── Employee.java │ ├── exclude │ │ ├── classlevel │ │ │ └── Employee.java │ │ └── fieldlevel │ │ │ └── Employee.java │ └── recursion │ │ ├── Manager.java │ │ ├── Employee.java │ │ └── RecursionClient.java │ ├── nonnull │ ├── EmployeeService.java │ ├── field │ │ └── Company.java │ └── EmployeeServiceDelomboked.java │ ├── getter │ ├── classlevel │ │ └── Account.java │ ├── fieldlevel │ │ └── Account.java │ └── configure │ │ └── Account.java │ └── log │ ├── Log4jClient.java │ ├── Slf4jClient.java │ ├── Log4j2Client.java │ ├── XSlf4jClient.java │ ├── JBossLogClient.java │ ├── CommonsLogClient.java │ ├── FLoggerClient.java │ └── LogClient.java ├── spring-core-2 ├── src │ ├── main │ │ ├── resources │ │ │ ├── spring.properties │ │ │ └── conditional │ │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── javabyexamples │ │ │ └── spring │ │ │ └── core │ │ │ ├── componentindex │ │ │ ├── PersonService.java │ │ │ ├── custom │ │ │ │ ├── CustomIndexed1.java │ │ │ │ ├── MultiComponent1.java │ │ │ │ └── CustomIndexed.java │ │ │ ├── javaxbased │ │ │ │ ├── NamedService.java │ │ │ │ └── SampleEntity1.java │ │ │ ├── indexedbased │ │ │ │ ├── SampleService1.java │ │ │ │ ├── SampleComponent1.java │ │ │ │ └── SampleRepository1.java │ │ │ └── DefaultPersonService.java │ │ │ ├── componentscan │ │ │ ├── level1 │ │ │ │ ├── level2 │ │ │ │ │ ├── MockRepository.java │ │ │ │ │ ├── Level2Service.java │ │ │ │ │ └── Level2Repository.java │ │ │ │ └── Level1Service.java │ │ │ └── scan │ │ │ │ └── DefaultComponentScanConfiguration.java │ │ │ ├── conditional │ │ │ ├── custom │ │ │ │ ├── AuditService.java │ │ │ │ ├── DefaultAuditService.java │ │ │ │ └── DummyAuditService.java │ │ │ ├── condition │ │ │ │ ├── AuditService.java │ │ │ │ └── DefaultAuditService.java │ │ │ └── configurationcondition │ │ │ │ ├── AuditService.java │ │ │ │ ├── DefaultAuditService.java │ │ │ │ └── DummyAuditService.java │ │ │ ├── usingbean │ │ │ ├── beandefinition │ │ │ │ ├── ServiceOne.java │ │ │ │ ├── ServiceTwo.java │ │ │ │ └── DefaultService.java │ │ │ ├── lifecycle │ │ │ │ ├── PersonService.java │ │ │ │ └── DefaultPersonService.java │ │ │ ├── beannaming │ │ │ │ ├── GreetingService.java │ │ │ │ └── DefaultGreetingService.java │ │ │ ├── cglibproxying │ │ │ │ ├── PostService.java │ │ │ │ ├── PostRepository.java │ │ │ │ ├── LogService.java │ │ │ │ └── DefaultPostRepository.java │ │ │ ├── incomponent │ │ │ │ ├── SampleService.java │ │ │ │ ├── SampleRepository.java │ │ │ │ ├── DefaultSampleRepository.java │ │ │ │ └── DefaultSampleService.java │ │ │ ├── beandependency │ │ │ │ ├── GreetingService.java │ │ │ │ └── GreetingProperties.java │ │ │ └── autowirecandidate │ │ │ │ ├── PersonRepository.java │ │ │ │ ├── PersonService.java │ │ │ │ ├── MockPersonRepository.java │ │ │ │ └── DefaultPersonRepository.java │ │ │ ├── initializecontext │ │ │ ├── service │ │ │ │ ├── GreetService.java │ │ │ │ └── DefaultGreetService.java │ │ │ └── ApplicationConfiguration.java │ │ │ ├── jsr330 │ │ │ ├── other │ │ │ │ └── EmployeeService.java │ │ │ ├── qualify │ │ │ │ ├── DepartmentRepository.java │ │ │ │ └── DepartmentService.java │ │ │ ├── JsrPersonRepository.java │ │ │ ├── PersonRepository.java │ │ │ ├── JsrFieldInjectionPersonService.java │ │ │ ├── JsrProviderInjectionPersonService.java │ │ │ ├── JsrSetterInjectionPersonService.java │ │ │ └── JsrConstructorInjectionPersonService.java │ │ │ ├── scopeddependency │ │ │ ├── servicelocator │ │ │ │ └── TimerFactory.java │ │ │ ├── beanlookup │ │ │ │ ├── ClientService.java │ │ │ │ └── Timer.java │ │ │ └── defaultbehavior │ │ │ │ └── AnotherClientService.java │ │ │ ├── importannotation │ │ │ ├── component │ │ │ │ ├── Counter.java │ │ │ │ └── MainConfiguration.java │ │ │ ├── configuration │ │ │ │ ├── Counter.java │ │ │ │ ├── ImpressionService.java │ │ │ │ └── CounterConfiguration.java │ │ │ ├── metaannotation │ │ │ │ ├── Counter.java │ │ │ │ ├── ImpressionService.java │ │ │ │ ├── CounterConfiguration.java │ │ │ │ └── MainConfiguration.java │ │ │ └── selector │ │ │ │ ├── ImpressionService.java │ │ │ │ ├── ProdCounterConfiguration.java │ │ │ │ ├── LocalCounterConfiguration.java │ │ │ │ └── Counter.java │ │ │ ├── eventlistener │ │ │ ├── RandomTemperature.java │ │ │ ├── TemperatureScreen.java │ │ │ └── TemperatureEvent.java │ │ │ └── closecontext │ │ │ └── MonitorService.java │ └── test │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── spring │ │ └── core │ │ └── jsr330 │ │ └── ApplicationTest.java └── README.md ├── java-and-test ├── wiremock │ └── src │ │ └── main │ │ ├── resources │ │ └── server │ │ │ ├── __files │ │ │ └── serveme.html │ │ │ └── mappings │ │ │ ├── hello-world.json │ │ │ ├── bye.json │ │ │ └── parameterized.json │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── java │ │ └── test │ │ └── wiremock │ │ └── server │ │ └── NoOpNotifier.java ├── testng │ ├── README.md │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── javabyexamples │ │ │ └── java │ │ │ └── test │ │ │ └── testng │ │ │ └── Grader.java │ │ └── test │ │ ├── resources │ │ └── suites │ │ │ ├── basic.xml │ │ │ ├── depends.xml │ │ │ ├── dataprovider.xml │ │ │ ├── annotation_order.xml │ │ │ ├── parameter.xml │ │ │ ├── group_football.xml │ │ │ └── group_basketball.xml │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── java │ │ └── test │ │ └── testng │ │ └── general │ │ ├── GroupTest.java │ │ ├── ParametersTest.java │ │ └── DependsOnTest.java ├── cucumber │ └── src │ │ └── test │ │ ├── resources │ │ ├── geckodriver │ │ └── com │ │ │ └── javabyexamples │ │ │ └── java │ │ │ └── test │ │ │ └── cucumber │ │ │ └── lesson4 │ │ │ └── lesson4.feature │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── java │ │ └── test │ │ └── cucumber │ │ ├── lesson2 │ │ └── package-info.java │ │ ├── lesson3 │ │ └── package-info.java │ │ ├── lesson1 │ │ └── package-info.java │ │ ├── lesson4 │ │ └── package-info.java │ │ └── lesson5 │ │ └── package-info.java ├── README.md ├── junit │ ├── README.md │ └── src │ │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── javabyexamples │ │ │ └── java │ │ │ └── test │ │ │ ├── assertj │ │ │ └── package-info.java │ │ │ ├── hamcrest │ │ │ └── package-info.java │ │ │ └── junit │ │ │ └── package-info.java │ │ └── main │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── java │ │ └── test │ │ └── junit │ │ └── Grader.java ├── jupiter │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── java │ │ └── test │ │ └── jupiter │ │ └── Calculator.java ├── mockito │ ├── src │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── javabyexamples │ │ │ └── java │ │ │ └── test │ │ │ └── mockito │ │ │ └── model │ │ │ └── Person.java │ └── README.md └── junitrule │ ├── src │ └── test │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── java │ │ └── test │ │ └── junit │ │ └── rule │ │ └── custom │ │ ├── monitor │ │ └── MonitorRuleTest.java │ │ └── ignore │ │ └── CustomIgnore.java │ └── README.md ├── spring-mvc-2 ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ ├── application-serverproperties.properties │ │ └── application-requestlogging.properties │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── spring │ │ └── mvc2 │ │ ├── apache │ │ ├── PingController.java │ │ └── Application.java │ │ ├── filter │ │ └── Application.java │ │ ├── serverconfiguration │ │ ├── properties │ │ │ ├── PingController.java │ │ │ └── Application.java │ │ └── tomcat │ │ │ ├── customizer │ │ │ ├── PingController.java │ │ │ └── Application.java │ │ │ └── factorycustomizer │ │ │ ├── PingController.java │ │ │ └── Application.java │ │ ├── readrequestbody │ │ └── caching │ │ │ └── Application.java │ │ └── requestlogging │ │ └── Application.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── README.md └── .gitignore ├── java-and-mapper ├── mapstruct │ ├── README.md │ └── src │ │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── javabyexamples │ │ │ └── java │ │ │ └── mapper │ │ │ └── mapstruct │ │ │ └── collection │ │ │ ├── Student.java │ │ │ ├── StudentDto.java │ │ │ └── primitive │ │ │ └── ListMapper.java │ │ └── test │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── java │ │ └── mapper │ │ └── mapstruct │ │ └── TestHelper.java └── orika │ ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── javabyexamples │ │ │ └── java │ │ │ └── mapper │ │ │ └── orika │ │ │ ├── generics │ │ │ └── package-info.java │ │ │ ├── immutable │ │ │ ├── Driver.java │ │ │ ├── DriverDto.java │ │ │ └── Car.java │ │ │ ├── basic │ │ │ └── PersonHelper.java │ │ │ └── mappingwithcollections │ │ │ └── Family.java │ └── test │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── java │ │ └── mapper │ │ └── orika │ │ └── generics │ │ ├── basic │ │ ├── Holder.java │ │ ├── AnotherHolder.java │ │ ├── PersonHolder.java │ │ └── AnotherPersonHolder.java │ │ └── collections │ │ ├── Group.java │ │ ├── Inventory.java │ │ ├── GroupDto.java │ │ ├── InventoryDto.java │ │ ├── PersonGroup.java │ │ └── PersonGroupDto.java │ └── README.md ├── spring-core └── src │ ├── main │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── spring │ │ └── core │ │ ├── beannaming │ │ ├── AuditService.java │ │ ├── ObsoleteAuditService.java │ │ ├── SimpleAuditService.java │ │ ├── LegacyAuditService.java │ │ └── AdvancedAuditService.java │ │ ├── usingprofiles │ │ ├── EmployeeService.java │ │ ├── DefaultEmployeeService.java │ │ ├── MockEmployeeService.java │ │ ├── RealEmployeeService.java │ │ ├── FastProdEmployeeService.java │ │ └── SlowProdEmployeeService.java │ │ ├── customqualifier │ │ ├── PersonService.java │ │ ├── V1PersonService.java │ │ ├── V2PersonService.java │ │ ├── Version1.java │ │ └── Version2.java │ │ ├── beanpostprocessor │ │ ├── GreetingService.java │ │ ├── EnglishGreetingService.java │ │ └── FrenchGreetingService.java │ │ ├── stereotypes │ │ ├── metaannotation │ │ │ ├── Generator.java │ │ │ ├── PrimaryGenerator.java │ │ │ └── SimpleGenerator.java │ │ ├── Planner.java │ │ ├── DepartmentService.java │ │ ├── DepartmentComponent.java │ │ ├── DepartmentController.java │ │ └── DepartmentRepository.java │ │ ├── disambiguatingbeans │ │ ├── CalculationService.java │ │ ├── NumberService.java │ │ ├── IntegerNumberService.java │ │ ├── LongNumberService.java │ │ ├── SimpleCalculationService.java │ │ └── AdvancedCalculationService.java │ │ ├── usingautowired │ │ ├── wiremultiple │ │ │ ├── GoodService.java │ │ │ ├── LocalGoodService.java │ │ │ └── ImportedGoodService.java │ │ ├── OrderService.java │ │ ├── EmployeeService.java │ │ └── ManagerService.java │ │ ├── javaconfig │ │ ├── Student.java │ │ ├── PrincipalService.java │ │ ├── TeacherService.java │ │ └── ClassService.java │ │ ├── annotationconfig │ │ ├── ChatRoomService.java │ │ ├── SettingsService.java │ │ └── HistoryService.java │ │ ├── awareinterfaces │ │ └── custom │ │ │ └── ActiveProfilesAware.java │ │ ├── beanfactorypostprocessor │ │ └── GreetingBean.java │ │ └── lifecycle │ │ └── CustomMethodsService.java │ └── test │ └── java │ └── com │ └── javabyexamples │ └── spring │ └── core │ ├── lifecycle │ └── ApplicationTest.java │ ├── beannaming │ └── ApplicationTest.java │ ├── javaconfig │ └── ApplicationTest.java │ ├── stereotypes │ └── ApplicationTest.java │ ├── usingautowired │ └── ApplicationTest.java │ ├── annotationconfig │ └── ApplicationTest.java │ ├── awareinterfaces │ └── ApplicationTest.java │ ├── beanpostprocessor │ └── ApplicationTest.java │ ├── customqualifier │ └── ApplicationTest.java │ └── disambiguatingbeans │ └── ApplicationTest.java ├── java-basics └── jar │ ├── executable-jar │ └── src │ │ └── main │ │ ├── resources │ │ └── MANIFEST.MF │ │ └── java │ │ └── com │ │ └── javabyexamples │ │ └── java │ │ └── jar │ │ └── Greeting.java │ └── jar-with-dependencies │ └── src │ └── main │ └── java │ └── com │ └── javabyexamples │ └── java │ └── jar │ └── HelloWorld.java ├── apache-httpclient-5 └── src │ └── main │ └── java │ └── com │ └── javabyexamples │ └── Main.java ├── lets.discuss └── src │ └── main │ └── java │ └── com │ └── javabyexamples │ └── lets │ └── discuss │ ├── decorator │ └── lombok │ │ └── README.md │ ├── builder │ └── compareToFluent │ │ ├── README.md │ │ └── fluent │ │ └── ClientMain.java │ └── strategy │ └── compareState │ ├── iteration1 │ ├── Printer.java │ ├── PrinterWithParameter.java │ ├── PrinterWithParameterImpl.java │ └── PrinterImpl.java │ ├── README.md │ ├── iteration3 │ └── WordFilter.java │ └── iteration2 │ ├── enhancement │ ├── WordFilter.java │ ├── BlackListWordFilter.java │ └── WhiteListWordFilter.java │ ├── WordFilter.java │ ├── BlackListWordFilter.java │ └── WhiteListWordFilter.java ├── java-core-1 └── src │ └── main │ └── java │ └── com │ └── javabyexamples │ └── java │ └── core │ └── classloader │ └── dynamic │ ├── Counter.java │ └── DefaultCounter.java ├── libraries-xstream └── src │ └── main │ ├── java │ └── com │ │ └── javabyexamples │ │ └── libraries │ │ └── xsteam │ │ ├── PhoneNumber.java │ │ └── Employee.java │ └── resources │ └── samples │ └── person.xml └── java-and-concurrency └── advanced └── src └── main └── java └── com └── javabyexamples └── java └── concurrency ├── buildingblocks └── cache │ ├── Computable.java │ └── ComputableCache.java ├── sharing └── visibility │ └── longvisibility │ └── LongHolder.java ├── composing ├── delegation │ ├── multiple │ │ └── Statistics.java │ └── single │ │ └── ImmutablePoint.java └── instanceconfinement │ └── MutablePoint.java ├── threadsafety └── atomicity │ └── racecondition │ └── readmodifywrite │ └── Incrementor.java └── common ├── annotation ├── Mutable.java ├── CanLeak.java ├── Delegated.java ├── Delegating.java ├── Immutable.java ├── StaleData.java ├── ThreadSafe.java ├── NonStaleData.java ├── InvariantHolds.java ├── NotThreadSafe.java ├── ThreadConfined.java ├── InvariantCanBreak.java ├── CannotLeak.java └── GuardedBy.java └── StopWatch.java /.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | **/.idea 3 | **/*.iml 4 | **/*.class -------------------------------------------------------------------------------- /apache-httpclient/src/main/resources/notes/todo.txt: -------------------------------------------------------------------------------- 1 | Hello world! -------------------------------------------------------------------------------- /spring-mvc-1/src/main/resources/templates/welcome.html: -------------------------------------------------------------------------------- 1 | Welcome -------------------------------------------------------------------------------- /maven-and-plugins/modules/module1/src/main/resources/db.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-core-3/src/main/resources/resource/rules.txt: -------------------------------------------------------------------------------- 1 | 1. hello world! -------------------------------------------------------------------------------- /spring-core-3/src/test/resources/resource/test-rules.txt: -------------------------------------------------------------------------------- 1 | 1. hi world! -------------------------------------------------------------------------------- /spring-mvc-1/src/main/resources/templates/templatelocation/hi.html: -------------------------------------------------------------------------------- 1 | Hi -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java By Examples 2 | Code examples for javabyexamples.com 3 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/resources/templates/suffixmatch/hello.html: -------------------------------------------------------------------------------- 1 | Hello! -------------------------------------------------------------------------------- /java-and-tools/README.md: -------------------------------------------------------------------------------- 1 | # Java and Tools 2 | Java tools and libraries 3 | -------------------------------------------------------------------------------- /maven-and-plugins/.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | **/*.iml 3 | **/.idea 4 | **/*.log -------------------------------------------------------------------------------- /spring-core-3/src/main/resources/fileasresource/hello.txt: -------------------------------------------------------------------------------- 1 | Hello World! 2 | -------------------------------------------------------------------------------- /spring-core-3/src/main/resources/propertysource/sample.properties: -------------------------------------------------------------------------------- 1 | hello=world -------------------------------------------------------------------------------- /spring-mvc-1/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8081 2 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/resources/templates/templatelocation/other/bye.html: -------------------------------------------------------------------------------- 1 | Bye -------------------------------------------------------------------------------- /maven-and-plugins/README.md: -------------------------------------------------------------------------------- 1 | # Maven and Plugins 2 | Maven plugin usage examples 3 | -------------------------------------------------------------------------------- /maven-and-plugins/failsafe/src/test/resources/sample.properties: -------------------------------------------------------------------------------- 1 | greet.german=Hallo -------------------------------------------------------------------------------- /maven-and-plugins/surefire/src/test/resources/sample.properties: -------------------------------------------------------------------------------- 1 | greet.german=Hallo -------------------------------------------------------------------------------- /spring-core-2/src/main/resources/spring.properties: -------------------------------------------------------------------------------- 1 | spring.index.ignore=true 2 | -------------------------------------------------------------------------------- /spring-core-3/README.md: -------------------------------------------------------------------------------- 1 | # Spring Framework Core Tutorials 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /java-and-test/wiremock/src/main/resources/server/__files/serveme.html: -------------------------------------------------------------------------------- 1 | Served directly! -------------------------------------------------------------------------------- /maven-and-plugins/buildhelper/imported/main/resources/imported.properties: -------------------------------------------------------------------------------- 1 | name=Imported -------------------------------------------------------------------------------- /maven-and-plugins/buildhelper/src/main/resources/my.properties: -------------------------------------------------------------------------------- 1 | name=Build helper plugin -------------------------------------------------------------------------------- /maven-and-plugins/resource/additional-resources/extraResource.txt: -------------------------------------------------------------------------------- 1 | Extra resource... 2 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/resources/templates/templatelocation/another/farewell.html: -------------------------------------------------------------------------------- 1 | Farewell -------------------------------------------------------------------------------- /spring-mvc-2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8081 2 | ajp.port=1600 -------------------------------------------------------------------------------- /java-and-test/testng/README.md: -------------------------------------------------------------------------------- 1 | # TestNG 2 | Seed project for TestNG to try its features 3 | -------------------------------------------------------------------------------- /spring-core-2/src/main/resources/conditional/application.properties: -------------------------------------------------------------------------------- 1 | audit.enabled=true 2 | -------------------------------------------------------------------------------- /maven-and-plugins/failsafe/src/test/resources/includes.txt: -------------------------------------------------------------------------------- 1 | */it/* 2 | %regex[.*IT.*|.*Live.*] 3 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/resources/application-requestmapping.properties: -------------------------------------------------------------------------------- 1 | resultsPath=public-results -------------------------------------------------------------------------------- /maven-and-plugins/resource/additional-resources/anotherExtraResource.txt: -------------------------------------------------------------------------------- 1 | Another extra resource... 2 | -------------------------------------------------------------------------------- /maven-and-plugins/resource/other-resources/environment/int/intResource.txt: -------------------------------------------------------------------------------- 1 | Integration resource... 2 | -------------------------------------------------------------------------------- /maven-and-plugins/resource/other-resources/environment/prod/prodResource.txt: -------------------------------------------------------------------------------- 1 | Production resource... 2 | -------------------------------------------------------------------------------- /maven-and-plugins/surefire/src/test/resources/excludes.txt: -------------------------------------------------------------------------------- 1 | */exclude/* 2 | %regex[.*IT.*|.*Live.*] 3 | -------------------------------------------------------------------------------- /maven-and-plugins/surefire/src/test/resources/includes.txt: -------------------------------------------------------------------------------- 1 | */test/* 2 | %regex[.*Test.*|.*Live.*] 3 | -------------------------------------------------------------------------------- /maven-and-plugins/failsafe/src/test/resources/excludes.txt: -------------------------------------------------------------------------------- 1 | */exclude/* 2 | %regex[.*Test.*|.*Live.*] 3 | -------------------------------------------------------------------------------- /maven-and-plugins/resource/other-resources/filtering/myFilter.properties: -------------------------------------------------------------------------------- 1 | myProp=This is a filter property -------------------------------------------------------------------------------- /maven-and-plugins/resource/src/main/resources/app.properties: -------------------------------------------------------------------------------- 1 | date1=${myDate} 2 | date2=@myDate@ 3 | prop1=@myProp@ -------------------------------------------------------------------------------- /maven-and-plugins/property/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost/test -------------------------------------------------------------------------------- /maven-and-plugins/resource/src/test/resources/appTest.properties: -------------------------------------------------------------------------------- 1 | date1=${myDate} 2 | date2=@myDate@ 3 | prop1=@myProp@ -------------------------------------------------------------------------------- /java-and-mapper/mapstruct/README.md: -------------------------------------------------------------------------------- 1 | # MapStruct Tutorials 2 | This project contains examples for the MapStruct bean mapping library. 3 | -------------------------------------------------------------------------------- /spring-mvc-1/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isaolmez/javabyexamples/HEAD/spring-mvc-1/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-mvc-2/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isaolmez/javabyexamples/HEAD/spring-mvc-2/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-mvc-1/src/main/resources/application-mdc.properties: -------------------------------------------------------------------------------- 1 | logging.pattern.console=%-4relative [%thread] %-5level %logger{35} %X{CorrelationId} --- %msg %n -------------------------------------------------------------------------------- /spring-mvc-1/src/main/resources/application-serverproperties.properties: -------------------------------------------------------------------------------- 1 | server.port=8081 2 | server.servlet.context-path=/api 3 | server.server-header=MyAppServer -------------------------------------------------------------------------------- /spring-mvc-2/src/main/resources/application-serverproperties.properties: -------------------------------------------------------------------------------- 1 | server.port=8082 2 | server.servlet.context-path=/api 3 | server.server-header=MyAppServer -------------------------------------------------------------------------------- /java-and-test/cucumber/src/test/resources/geckodriver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isaolmez/javabyexamples/HEAD/java-and-test/cucumber/src/test/resources/geckodriver -------------------------------------------------------------------------------- /spring-mvc-1/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-mvc-2/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /java-and-test/README.md: -------------------------------------------------------------------------------- 1 | # Java and Test 2 | Covers the commonly used testing libraries in Java ecosystem 3 | - JUnit 4 | - TestNG 5 | - Mockito 6 | - Cucumber 7 | - Jsonpath 8 | -------------------------------------------------------------------------------- /java-and-test/junit/README.md: -------------------------------------------------------------------------------- 1 | # JUnit 2 | JUnit seed to showcase its features. 3 | Also showcases 3 different assertion libraries: 4 | - JUnit 5 | - Hamcrest 6 | - AssertJ 7 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/resources/templates/model/greet.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello ! 5 | 6 | -------------------------------------------------------------------------------- /spring-core-2/README.md: -------------------------------------------------------------------------------- 1 | # Spring Framework Core Tutorials 2 | 3 | - [Spring with JSR-330 Annotations](http://www.javabyexamples.com/using-jsr-330-annotations-with-spring/) 4 | 5 | 6 | -------------------------------------------------------------------------------- /java-and-test/junit/src/test/java/com/javabyexamples/java/test/assertj/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Tests using AssertJ assertions 3 | */ 4 | package com.javabyexamples.java.test.assertj; 5 | -------------------------------------------------------------------------------- /spring-core-3/src/main/java/com/javabyexamples/spring/core/resource/package-info.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.resource; 2 | 3 | /*** 4 | * It is covered in tests. 5 | */ 6 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/beannaming/AuditService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.beannaming; 2 | 3 | public interface AuditService { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /spring-mvc-2/src/main/resources/application-requestlogging.properties: -------------------------------------------------------------------------------- 1 | logging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=DEBUG 2 | 3 | 4 | request.logging.shouldLog=true -------------------------------------------------------------------------------- /java-and-test/junit/src/test/java/com/javabyexamples/java/test/hamcrest/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Tests using Hamcrest assertions 3 | */ 4 | package com.javabyexamples.java.test.hamcrest; 5 | -------------------------------------------------------------------------------- /java-and-test/junit/src/test/java/com/javabyexamples/java/test/junit/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Tests using default junit assertions 3 | */ 4 | package com.javabyexamples.java.test.junit; 5 | -------------------------------------------------------------------------------- /spring-core-3/src/main/java/com/javabyexamples/spring/core/spel/basic/package-info.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.spel.basic; 2 | 3 | /*** 4 | * It is covered in tests. 5 | */ 6 | -------------------------------------------------------------------------------- /java-basics/jar/executable-jar/src/main/resources/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Created-By: Maven Archiver 3.4.0 3 | Build-Jdk-Spec: 11 4 | Main-Class: com.javabyexamples.java.jar.Greeting 5 | -------------------------------------------------------------------------------- /java-and-test/junit/src/main/java/com/javabyexamples/java/test/junit/Grader.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.junit; 2 | 3 | public interface Grader { 4 | 5 | String grade(int grade); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentindex/PersonService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentindex; 2 | 3 | public interface PersonService { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/usingprofiles/EmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingprofiles; 2 | 3 | public interface EmployeeService { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/resources/templates/introduction/homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ! 5 | 6 | -------------------------------------------------------------------------------- /java-and-test/testng/src/main/java/com/javabyexamples/java/test/testng/Grader.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.testng; 2 | 3 | public interface Grader { 4 | 5 | String grade(int grade); 6 | } 7 | -------------------------------------------------------------------------------- /maven-and-plugins/failsafe/src/test/java/com/javabyexamples/maven/plugins/failsafe/groups/FastTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.failsafe.groups; 2 | 3 | public interface FastTest { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /maven-and-plugins/failsafe/src/test/java/com/javabyexamples/maven/plugins/failsafe/groups/SlowTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.failsafe.groups; 2 | 3 | public interface SlowTest { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /maven-and-plugins/surefire/src/test/java/com/javabyexamples/maven/plugins/surefire/groups/FastTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.surefire.groups; 2 | 3 | public interface FastTest { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /maven-and-plugins/surefire/src/test/java/com/javabyexamples/maven/plugins/surefire/groups/SlowTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.surefire.groups; 2 | 3 | public interface SlowTest { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithjson/view/PrivateDetails.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithjson.view; 2 | 3 | public interface PrivateDetails { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /java-and-test/cucumber/src/test/java/com/javabyexamples/java/test/cucumber/lesson2/package-info.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.cucumber.lesson2; 2 | /** 3 | * Scenario with "Outline" showing examples 4 | */ 5 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/resources/templates/introduction/comment.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | : 5 | 6 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentscan/level1/level2/MockRepository.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentscan.level1.level2; 2 | 3 | public class MockRepository { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/beannaming/ObsoleteAuditService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.beannaming; 2 | 3 | public class ObsoleteAuditService implements AuditService { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/beannaming/SimpleAuditService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.beannaming; 2 | 3 | public class SimpleAuditService implements AuditService { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/customqualifier/PersonService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.customqualifier; 2 | 3 | public interface PersonService { 4 | 5 | void hello(); 6 | } 7 | -------------------------------------------------------------------------------- /apache-httpclient-5/src/main/java/com/javabyexamples/Main.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } -------------------------------------------------------------------------------- /java-and-mapper/orika/src/main/java/com/javabyexamples/java/mapper/orika/generics/package-info.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.generics; 2 | /** 3 | * Generics examples are covered in the test cases. 4 | */ 5 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/conditional/custom/AuditService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.conditional.custom; 2 | 3 | public interface AuditService { 4 | 5 | void audit(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithjson/view/PublicDetails.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithjson.view; 2 | 3 | public interface PublicDetails extends PrivateDetails { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /java-and-test/cucumber/src/test/java/com/javabyexamples/java/test/cucumber/lesson3/package-info.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.cucumber.lesson3; 2 | /** 3 | * Tag usage in scenario feature files and in the runner 4 | */ 5 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentindex/custom/CustomIndexed1.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentindex.custom; 2 | 3 | @CustomIndexed 4 | public class CustomIndexed1 { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/conditional/condition/AuditService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.conditional.condition; 2 | 3 | public interface AuditService { 4 | 5 | void audit(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/beandefinition/ServiceOne.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.beandefinition; 2 | 3 | public interface ServiceOne { 4 | 5 | void one(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/beandefinition/ServiceTwo.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.beandefinition; 2 | 3 | public interface ServiceTwo { 4 | 5 | void two(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/lifecycle/PersonService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.lifecycle; 2 | 3 | public interface PersonService { 4 | 5 | void work(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/beanpostprocessor/GreetingService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.beanpostprocessor; 2 | 3 | public interface GreetingService { 4 | 5 | void hello(); 6 | } 7 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/decorator/lombok/README.md: -------------------------------------------------------------------------------- 1 | # Java By Examples 2 | Implementations here are explained in following blog posts: 3 | 4 | http://www.javabyexamples.com/decorator-pattern-with-lombok/ 5 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/beannaming/GreetingService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.beannaming; 2 | 3 | public interface GreetingService { 4 | 5 | void greet(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/cglibproxying/PostService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.cglibproxying; 2 | 3 | public interface PostService { 4 | 5 | void save(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/incomponent/SampleService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.incomponent; 2 | 3 | public interface SampleService { 4 | 5 | void perform(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/stereotypes/metaannotation/Generator.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.stereotypes.metaannotation; 2 | 3 | public interface Generator { 4 | 5 | void generate(); 6 | } 7 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/builder/compareToFluent/README.md: -------------------------------------------------------------------------------- 1 | # Java By Examples 2 | Implementations here are explained in following blog posts: 3 | 4 | http://www.javabyexamples.com/builder-vs-fluent-interface/ 5 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/initializecontext/service/GreetService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.initializecontext.service; 2 | 3 | public interface GreetService { 4 | 5 | void greet(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/cglibproxying/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.cglibproxying; 2 | 3 | public interface PostRepository { 4 | 5 | void save(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/incomponent/SampleRepository.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.incomponent; 2 | 3 | public interface SampleRepository { 4 | 5 | void save(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/disambiguatingbeans/CalculationService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.disambiguatingbeans; 2 | 3 | public interface CalculationService { 4 | 5 | void calculate(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/disambiguatingbeans/NumberService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.disambiguatingbeans; 2 | 3 | public interface NumberService { 4 | 5 | T get(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/usingautowired/wiremultiple/GoodService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingautowired.wiremultiple; 2 | 3 | public interface GoodService { 4 | 5 | void buy(); 6 | } 7 | -------------------------------------------------------------------------------- /java-core-1/src/main/java/com/javabyexamples/java/core/classloader/dynamic/Counter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.core.classloader.dynamic; 2 | 3 | public interface Counter { 4 | 5 | String message(); 6 | 7 | int plusPlus(); 8 | } 9 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/strategy/compareState/iteration1/Printer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.lets.discuss.strategy.compareState.iteration1; 2 | 3 | public interface Printer { 4 | 5 | void print(); 6 | } 7 | -------------------------------------------------------------------------------- /libraries-xstream/src/main/java/com/javabyexamples/libraries/xsteam/PhoneNumber.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.libraries.xsteam; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class PhoneNumber { 7 | 8 | private final String number; 9 | } -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/beandependency/GreetingService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.beandependency; 2 | 3 | public interface GreetingService { 4 | 5 | void greet(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/stereotypes/Planner.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.stereotypes; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class Planner { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /java-and-test/cucumber/src/test/java/com/javabyexamples/java/test/cucumber/lesson1/package-info.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.cucumber.lesson1; 2 | /** 3 | * - Hooks usage - Multiple scenarios with "Background" and "But" usage... 4 | */ 5 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/strategy/compareState/README.md: -------------------------------------------------------------------------------- 1 | # Java By Examples 2 | Implementations here are explained in following blog posts: 3 | 4 | http://www.javabyexamples.com/strategy-pattern-stateless-or-stateful/ 5 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/autowirecandidate/PersonRepository.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.autowirecandidate; 2 | 3 | public interface PersonRepository { 4 | 5 | void save(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/autowirecandidate/PersonService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.autowirecandidate; 2 | 3 | public interface PersonService { 4 | 5 | void perform(); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/javaconfig/Student.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.javaconfig; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class Student { 7 | 8 | private String name; 9 | } 10 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/model/Greeting.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.model; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class Greeting { 7 | 8 | private final String name; 9 | } 10 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithjson/Query.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithjson; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Query { 7 | 8 | private String name; 9 | } 10 | -------------------------------------------------------------------------------- /java-and-test/wiremock/src/main/resources/server/mappings/hello-world.json: -------------------------------------------------------------------------------- 1 | { 2 | "request": { 3 | "url": "/hello", 4 | "method": "GET" 5 | }, 6 | "response": { 7 | "status": 200, 8 | "body": "Hello world!" 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/jsr330/other/EmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.jsr330.other; 2 | 3 | import javax.annotation.ManagedBean; 4 | 5 | @ManagedBean 6 | public class EmployeeService { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/currentrequest/Person.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.currentrequest; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Person { 7 | 8 | private String name; 9 | } 10 | -------------------------------------------------------------------------------- /java-and-test/cucumber/src/test/java/com/javabyexamples/java/test/cucumber/lesson4/package-info.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.cucumber.lesson4; 2 | /** 3 | * External hooks to be run before and after tests. Scenario parameter in the methods 4 | */ 5 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentindex/javaxbased/NamedService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentindex.javaxbased; 2 | 3 | import javax.inject.Named; 4 | 5 | @Named 6 | public class NamedService { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/conditional/configurationcondition/AuditService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.conditional.configurationcondition; 2 | 3 | public interface AuditService { 4 | 5 | void audit(); 6 | } 7 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/strategy/compareState/iteration3/WordFilter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.lets.discuss.strategy.compareState.iteration3; 2 | 3 | public interface WordFilter { 4 | 5 | boolean filter(String word); 6 | } 7 | -------------------------------------------------------------------------------- /maven-and-plugins/buildhelper/imported/main/java/com/javabyexamples/maven/plugins/buildhelper/Job.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.buildhelper; 2 | 3 | public class Job { 4 | 5 | public String work() { 6 | return "working"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/stereotypes/DepartmentService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.stereotypes; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | @Service 6 | public class DepartmentService { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/buildingblocks/cache/Computable.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.buildingblocks.cache; 2 | 3 | public interface Computable { 4 | 5 | V compute(A arg); 6 | } 7 | -------------------------------------------------------------------------------- /java-and-test/cucumber/src/test/java/com/javabyexamples/java/test/cucumber/lesson5/package-info.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.cucumber.lesson5; 2 | /** 3 | * CucumberOptions usage and "Test" extension to be picked up by surefire plugin for unit tests 4 | */ 5 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/jsr330/qualify/DepartmentRepository.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.jsr330.qualify; 2 | 3 | import javax.inject.Named; 4 | 5 | @Named("department") 6 | public class DepartmentRepository { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/stereotypes/DepartmentComponent.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.stereotypes; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class DepartmentComponent { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /java-and-test/jupiter/src/main/java/com/javabyexamples/java/test/jupiter/Calculator.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.jupiter; 2 | 3 | public class Calculator { 4 | 5 | public int multiply(int first, int second) { 6 | return first * second; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /maven-and-plugins/compile/src/main/java/com/javabyexamples/maven/plugins/compiler/Main.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.compiler; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("Hi"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentscan/level1/Level1Service.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentscan.level1; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | @Service 6 | public class Level1Service { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/stereotypes/DepartmentController.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.stereotypes; 2 | 3 | import org.springframework.stereotype.Controller; 4 | 5 | @Controller 6 | public class DepartmentController { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/usingautowired/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingautowired; 2 | 3 | public class OrderService { 4 | 5 | public void order() { 6 | System.out.println("Ordering"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/jacksonconfiguration/Query.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.jacksonconfiguration; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Query { 7 | 8 | private String searchTerm; 9 | } 10 | -------------------------------------------------------------------------------- /libraries-xstream/src/main/resources/samples/person.xml: -------------------------------------------------------------------------------- 1 | 2 | John 3 | Doe 4 | 5 | 0221 6 | 7 | 8 | 0222 9 | 10 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=debug, stdout 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/strategy/compareState/iteration1/PrinterWithParameter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.lets.discuss.strategy.compareState.iteration1; 2 | 3 | public interface PrinterWithParameter { 4 | 5 | void print(String value); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentindex/indexedbased/SampleService1.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentindex.indexedbased; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | @Service 6 | public class SampleService1 { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentscan/level1/level2/Level2Service.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentscan.level1.level2; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | @Service 6 | public class Level2Service { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/cglibproxying/LogService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.cglibproxying; 2 | 3 | public class LogService { 4 | 5 | public void log() { 6 | System.out.println("Logging..."); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/beannaming/LegacyAuditService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.beannaming; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class LegacyAuditService implements AuditService { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/javaconfig/PrincipalService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.javaconfig; 2 | 3 | public class PrincipalService { 4 | 5 | public void administer() { 6 | System.out.println("Administering the school."); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/javaconfig/TeacherService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.javaconfig; 2 | 3 | public class TeacherService { 4 | 5 | public void teach(Student student) { 6 | System.out.println("Teaching " + student); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentindex/indexedbased/SampleComponent1.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentindex.indexedbased; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class SampleComponent1 { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentscan/level1/level2/Level2Repository.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentscan.level1.level2; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | @Repository 6 | public class Level2Repository { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/scopeddependency/servicelocator/TimerFactory.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.scopeddependency.servicelocator; 2 | 3 | public interface TimerFactory { 4 | 5 | Timer getTimer(); 6 | 7 | Timer getTimer(String name); 8 | } 9 | -------------------------------------------------------------------------------- /spring-core-3/src/test/java/com/javabyexamples/spring/core/spel/basic/Person.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.spel.basic; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Person { 7 | 8 | private String name; 9 | private Address address = new Address(); 10 | } 11 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/controller/Message.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.controller; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class Message { 7 | 8 | private final String message; 9 | private final String name; 10 | } 11 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentindex/DefaultPersonService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentindex; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class DefaultPersonService implements PersonService { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentindex/indexedbased/SampleRepository1.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentindex.indexedbased; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | @Repository 6 | public class SampleRepository1 { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /spring-core-3/src/test/java/com/javabyexamples/spring/core/spel/basic/Address.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.spel.basic; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Address { 7 | 8 | private String street = "unknown"; 9 | private String city = "unknown"; 10 | } 11 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/sharing/visibility/longvisibility/LongHolder.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.sharing.visibility.longvisibility; 2 | 3 | public interface LongHolder { 4 | 5 | void alternate(); 6 | 7 | long getCounter(); 8 | } 9 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/data/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.data; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Employee { 7 | 8 | private String name; 9 | private int salary; 10 | } 11 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/value/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.value; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class Employee { 7 | 8 | private String name; 9 | private int salary; 10 | } 11 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithxml/castor/PersonCriteria.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithxml.castor; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class PersonCriteria { 7 | 8 | private String name; 9 | 10 | private String lastName; 11 | } 12 | -------------------------------------------------------------------------------- /java-and-test/cucumber/src/test/resources/com/javabyexamples/java/test/cucumber/lesson4/lesson4.feature: -------------------------------------------------------------------------------- 1 | Feature: Scenario with multiple hooks. 2 | 3 | Scenario: Login should fail 4 | Given I am on Facebook login page 5 | When I enter username as "john" 6 | And I enter password as "doe" 7 | Then Login should fail -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/inheritance/Person.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.inheritance; 2 | 3 | import lombok.ToString; 4 | 5 | @ToString 6 | public class Person { 7 | 8 | private String country; 9 | } 10 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/strategy/compareState/iteration2/enhancement/WordFilter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.lets.discuss.strategy.compareState.iteration2.enhancement; 2 | 3 | public interface WordFilter { 4 | 5 | boolean filter(String word, WordFilterOptions wordFilterOptions); 6 | } 7 | -------------------------------------------------------------------------------- /spring-core-3/src/test/java/com/javabyexamples/spring/core/spel/rootobject/Address.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.spel.rootobject; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Address { 7 | 8 | private String street; 9 | private String city; 10 | private String country; 11 | } 12 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/requestresponsebodyadvice/Answer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.requestresponsebodyadvice; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Answer { 7 | 8 | private String answerMessage; 9 | private Question question; 10 | } 11 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/setter/Account.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.setter; 2 | 3 | import lombok.Setter; 4 | 5 | @Setter 6 | public class Account { 7 | 8 | private String username; 9 | private String password; 10 | } 11 | -------------------------------------------------------------------------------- /spring-core-3/src/main/java/com/javabyexamples/spring/core/propertysource/placeholder/package-info.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.propertysource.placeholder; 2 | 3 | /** 4 | * If application context has a PropertySourcesPlaceholderConfigurer bean, it also looks for environment and its 5 | * property sources. 6 | */ 7 | -------------------------------------------------------------------------------- /java-and-test/wiremock/src/main/resources/server/mappings/bye.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "9c8dc74d-af5b-48ff-a443-9d3d5bfd7841", 3 | "request": { 4 | "url": "/bye", 5 | "method": "GET" 6 | }, 7 | "response": { 8 | "status": 200, 9 | "body": "Bye" 10 | }, 11 | "uuid": "9c8dc74d-af5b-48ff-a443-9d3d5bfd7841" 12 | } -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/importannotation/component/Counter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.importannotation.component; 2 | 3 | public class Counter { 4 | 5 | private int current = 0; 6 | 7 | public void count() { 8 | System.out.println(current++); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/jsr330/JsrPersonRepository.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.jsr330; 2 | 3 | import javax.inject.Named; 4 | 5 | @Named 6 | public class JsrPersonRepository { 7 | 8 | public void list() { 9 | System.out.println("Listing person"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/builder/classlevel/Student.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.builder.classlevel; 2 | 3 | import lombok.Builder; 4 | 5 | @Builder 6 | public class Student { 7 | 8 | private String name; 9 | private int age; 10 | } 11 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/strategy/compareState/iteration2/WordFilter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.lets.discuss.strategy.compareState.iteration2; 2 | 3 | import java.util.List; 4 | 5 | public interface WordFilter { 6 | 7 | boolean filter(String word, List whiteList, List blackList); 8 | } 9 | -------------------------------------------------------------------------------- /maven-and-plugins/failsafe/src/main/java/com/javabyexamples/maven/plugins/failsafe/Person.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.failsafe; 2 | 3 | public class Person { 4 | 5 | public String sayHello() { 6 | return "Hello"; 7 | } 8 | 9 | public String sayBye() { 10 | return "Bye"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/importannotation/configuration/Counter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.importannotation.configuration; 2 | 3 | public class Counter { 4 | 5 | private int current = 0; 6 | 7 | public void count() { 8 | System.out.println(current++); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/basic/Developer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.basic; 2 | 3 | import lombok.ToString; 4 | 5 | @ToString 6 | public class Developer { 7 | 8 | private String name; 9 | private String language; 10 | } 11 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/importannotation/metaannotation/Counter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.importannotation.metaannotation; 2 | 3 | public class Counter { 4 | 5 | private int current = 0; 6 | 7 | public void count() { 8 | System.out.println(current++); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/requestresponsebodyadvice/Question.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.requestresponsebodyadvice; 2 | 3 | import java.util.Date; 4 | import lombok.Data; 5 | 6 | @Data 7 | public class Question { 8 | 9 | private String questionMessage; 10 | private Date date; 11 | } 12 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithxml/castor/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithxml.castor; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class PersonDetails { 7 | 8 | private String name; 9 | 10 | private String lastName; 11 | 12 | private int age; 13 | } 14 | -------------------------------------------------------------------------------- /java-and-test/wiremock/src/main/resources/server/mappings/parameterized.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "9c8dc74d-af5b-48ff-a443-9d3d5bfd7841", 3 | "request": { 4 | "url": "/greet/([A-Z])", 5 | "method": "GET" 6 | }, 7 | "response": { 8 | "status": 200, 9 | "body": "Bye" 10 | }, 11 | "uuid": "9c8dc74d-af5b-48ff-a443-9d3d5bfd7841" 12 | } -------------------------------------------------------------------------------- /libraries-xstream/src/main/java/com/javabyexamples/libraries/xsteam/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.libraries.xsteam; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Employee { 7 | 8 | private String name; 9 | private String lastname; 10 | private PhoneNumber personal; 11 | private PhoneNumber work; 12 | } 13 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentindex/javaxbased/SampleEntity1.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentindex.javaxbased; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | 6 | @Entity 7 | public class SampleEntity1 { 8 | 9 | @Id 10 | private String id; 11 | } 12 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/beannaming/DefaultGreetingService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.beannaming; 2 | 3 | public class DefaultGreetingService implements GreetingService { 4 | 5 | @Override 6 | public void greet() { 7 | System.out.println("Hi"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/composing/delegation/multiple/Statistics.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.composing.delegation.multiple; 2 | 3 | public interface Statistics { 4 | 5 | void update(); 6 | 7 | boolean invariantHolds(); 8 | 9 | void print(); 10 | } 11 | -------------------------------------------------------------------------------- /java-and-mapper/orika/README.md: -------------------------------------------------------------------------------- 1 | ## Orika JavaBeans Mapper Tutorials 2 | 3 | - [Quick Guide to Orika](http://www.javabyexamples.com/quick-guide-to-orika) 4 | - [Mapping Collections using Orika](http://www.javabyexamples.com/mapping-collections-using-orika) 5 | - [Mapping with Generics using Orika](http://www.javabyexamples.com/mapping-with-generics-using-orika) 6 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/constructors/allargs/parent/Citizen.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.constructors.allargs.parent; 2 | 3 | //@AllArgsConstructor // Employee @AllArgsConstructor fails when enabled 4 | public class Citizen { 5 | 6 | private String country; 7 | } 8 | -------------------------------------------------------------------------------- /maven-and-plugins/surefire/src/main/java/com/javabyexamples/maven/plugins/surefire/Person.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.surefire; 2 | 3 | public class Person { 4 | 5 | public String run() { 6 | return "Running"; 7 | } 8 | 9 | public String runTenLaps() { 10 | return "Running ten laps"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /maven-and-plugins/surefire/src/test/java/com/javabyexamples/maven/plugins/surefire/SampleE2E.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.surefire; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class SampleE2E { 7 | 8 | @Test 9 | public void shouldTest() { 10 | Assert.assertTrue(true); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentindex/custom/MultiComponent1.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentindex.custom; 2 | 3 | import javax.inject.Named; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @CustomIndexed 8 | @Named 9 | public class MultiComponent1 { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/jsr330/PersonRepository.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.jsr330; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | @Repository 6 | public class PersonRepository { 7 | 8 | public void list() { 9 | System.out.println("Listing person"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/equalsandhashcode/inheritance/Citizen.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.equalsandhashcode.inheritance; 2 | 3 | import lombok.EqualsAndHashCode; 4 | 5 | @EqualsAndHashCode 6 | public class Citizen { 7 | 8 | private String country; 9 | } 10 | -------------------------------------------------------------------------------- /maven-and-plugins/surefire/src/test/java/com/javabyexamples/maven/plugins/surefire/E2ETestCase1.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.surefire; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class E2ETestCase1 { 7 | 8 | @Test 9 | public void shouldTest() { 10 | Assert.assertTrue(true); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/beandependency/GreetingProperties.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.beandependency; 2 | 3 | public class GreetingProperties { 4 | 5 | private final String greeting = "Hi"; 6 | 7 | public String getGreeting() { 8 | return greeting; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/cglibproxying/DefaultPostRepository.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.cglibproxying; 2 | 3 | public class DefaultPostRepository implements PostRepository { 4 | 5 | @Override 6 | public void save() { 7 | System.out.println("Saving..."); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/usingautowired/EmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingautowired; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class EmployeeService { 7 | 8 | public void work() { 9 | System.out.println("Working"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/usingautowired/ManagerService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingautowired; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class ManagerService { 7 | 8 | public void manage() { 9 | System.out.println("Managing"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithjson/Customer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithjson; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Customer { 7 | 8 | private String name; 9 | private String lastName; 10 | private String country; 11 | private String creditCardNumber; 12 | } 13 | -------------------------------------------------------------------------------- /java-basics/jar/jar-with-dependencies/src/main/java/com/javabyexamples/java/jar/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.jar; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | public class HelloWorld { 6 | 7 | public static void main(String[] args) { 8 | System.out.println(StringUtils.upperCase("Hello World")); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/jsr330/JsrFieldInjectionPersonService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.jsr330; 2 | 3 | import javax.inject.Inject; 4 | import javax.inject.Named; 5 | 6 | @Named 7 | public class JsrFieldInjectionPersonService { 8 | 9 | @Inject 10 | private PersonRepository personRepository; 11 | } 12 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/incomponent/DefaultSampleRepository.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.incomponent; 2 | 3 | public class DefaultSampleRepository implements SampleRepository { 4 | 5 | @Override 6 | public void save() { 7 | System.out.println("Saving..."); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /spring-mvc-2/README.md: -------------------------------------------------------------------------------- 1 | # Spring MVC Tutorials 2 | 3 | - [Create Filter with Spring MVC](http://www.javabyexamples.com/creating-filter-using-spring-mvc) 4 | - [Read Request Body Multiple Times](http://www.javabyexamples.com/read-request-body-multiple-times-using-spring-mvc) 5 | - [Request Logging with Spring MVC](http://www.javabyexamples.com/request-logging-using-spring-mvc) -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/data/staticconstructor/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.data.staticconstructor; 2 | 3 | import lombok.Data; 4 | 5 | @Data(staticConstructor = "of") 6 | public class Employee { 7 | 8 | private String name; 9 | private int salary; 10 | } 11 | -------------------------------------------------------------------------------- /maven-and-plugins/surefire/src/test/java/com/javabyexamples/maven/plugins/surefire/SampleTestCase1.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.surefire; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class SampleTestCase1 { 7 | 8 | @Test 9 | public void shouldTest() { 10 | Assert.assertTrue(true); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/autowirecandidate/MockPersonRepository.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.autowirecandidate; 2 | 3 | public class MockPersonRepository implements PersonRepository { 4 | 5 | @Override 6 | public void save() { 7 | System.out.println("Mocking..."); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/usingprofiles/DefaultEmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingprofiles; 2 | 3 | import org.springframework.context.annotation.Profile; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @Profile("default") 8 | public class DefaultEmployeeService { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/resources/application-jacksonconfigure.properties: -------------------------------------------------------------------------------- 1 | spring.jackson.deserialization.WRAP_EXCEPTIONS=false 2 | spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false 3 | spring.jackson.property-naming-strategy=SNAKE_CASE 4 | spring.jackson.default-property-inclusion=non_null 5 | spring.jackson.serialization.indent_output=true 6 | spring.jackson.time-zone=GMT+8 -------------------------------------------------------------------------------- /java-and-mapper/orika/src/main/java/com/javabyexamples/java/mapper/orika/immutable/Driver.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.immutable; 2 | 3 | public class Driver { 4 | 5 | private final Car car; 6 | 7 | public Driver(Car car) { 8 | this.car = car; 9 | } 10 | 11 | public Car getCar() { 12 | return car; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /java-and-test/testng/src/test/resources/suites/basic.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/constructors/noargs/EmployeeDelomboked.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.constructors.noargs; 2 | 3 | public class EmployeeDelomboked { 4 | 5 | private String name; 6 | private int salary; 7 | 8 | public EmployeeDelomboked() { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/equalsandhashcode/basic/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.equalsandhashcode.basic; 2 | 3 | import lombok.EqualsAndHashCode; 4 | 5 | @EqualsAndHashCode 6 | public class Employee { 7 | 8 | private String name; 9 | private int salary; 10 | } 11 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/nonnull/EmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.nonnull; 2 | 3 | import lombok.NonNull; 4 | 5 | public class EmployeeService { 6 | 7 | public void increaseSalary(@NonNull String name) { 8 | System.out.println(name); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/value/staticconstructor/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.value.staticconstructor; 2 | 3 | import lombok.Value; 4 | 5 | @Value(staticConstructor = "of") 6 | public class Employee { 7 | 8 | private String name; 9 | private int salary; 10 | } 11 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/autowirecandidate/DefaultPersonRepository.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.autowirecandidate; 2 | 3 | public class DefaultPersonRepository implements PersonRepository { 4 | 5 | @Override 6 | public void save() { 7 | System.out.println("Saving..."); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/annotationconfig/ChatRoomService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.annotationconfig; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class ChatRoomService { 7 | 8 | public void start() { 9 | System.out.println("Starting chat room"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/annotationconfig/SettingsService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.annotationconfig; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class SettingsService { 7 | 8 | public void configure() { 9 | System.out.println("Configuring chat"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/buildingblocks/cache/ComputableCache.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.buildingblocks.cache; 2 | 3 | import java.util.Map; 4 | 5 | public interface ComputableCache extends Computable { 6 | 7 | Map getCache(); 8 | 9 | int getPutCount(); 10 | } 11 | -------------------------------------------------------------------------------- /java-and-test/testng/src/test/resources/suites/depends.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/fieldname/Developer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.fieldname; 2 | 3 | import lombok.ToString; 4 | 5 | @ToString(includeFieldNames = false) 6 | public class Developer { 7 | 8 | private String name; 9 | private String language; 10 | } 11 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/stereotypes/DepartmentRepository.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.stereotypes; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | @Repository 6 | public class DepartmentRepository { 7 | 8 | public void save() { 9 | throw new RuntimeException("Planned exception"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/main/java/com/javabyexamples/java/mapper/orika/immutable/DriverDto.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.immutable; 2 | 3 | public class DriverDto { 4 | 5 | private final Car car; 6 | 7 | public DriverDto(Car car) { 8 | this.car = car; 9 | } 10 | 11 | public Car getCar() { 12 | return car; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/getter/classlevel/Account.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.getter.classlevel; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Getter 7 | @Setter 8 | public class Account { 9 | 10 | private String username; 11 | private String password; 12 | } 13 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/annotationconfig/HistoryService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.annotationconfig; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component("history") 6 | public class HistoryService { 7 | 8 | public void store() { 9 | System.out.println("Storing the history"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/stereotypes/metaannotation/PrimaryGenerator.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.stereotypes.metaannotation; 2 | 3 | @PrimaryComponent 4 | public class PrimaryGenerator implements Generator { 5 | 6 | @Override 7 | public void generate() { 8 | System.out.println("Advanced generator"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/threadsafety/atomicity/racecondition/readmodifywrite/Incrementor.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.threadsafety.atomicity.racecondition.readmodifywrite; 2 | 3 | public interface Incrementor { 4 | 5 | void increment(); 6 | 7 | void reset(); 8 | 9 | int get(); 10 | } 11 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/inheritance/Developer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.inheritance; 2 | 3 | import lombok.ToString; 4 | 5 | @ToString(callSuper = true) 6 | public class Developer extends Person { 7 | 8 | private String name; 9 | private String language; 10 | } 11 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/awareinterfaces/custom/ActiveProfilesAware.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.awareinterfaces.custom; 2 | 3 | import java.util.List; 4 | import org.springframework.beans.factory.Aware; 5 | 6 | public interface ActiveProfilesAware extends Aware { 7 | 8 | void setActiveProfiles(List activeProfiles); 9 | } 10 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/beanfactorypostprocessor/GreetingBean.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.beanfactorypostprocessor; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component("greetingBean") 6 | public class GreetingBean { 7 | 8 | public void sayHello() { 9 | System.out.println("Hello!"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/disambiguatingbeans/IntegerNumberService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.disambiguatingbeans; 2 | 3 | public class IntegerNumberService implements NumberService { 4 | 5 | @Override 6 | public Integer get() { 7 | System.out.println("Returning integer"); 8 | return 1; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/usingprofiles/MockEmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingprofiles; 2 | 3 | import org.springframework.context.annotation.Profile; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @Profile("!prod") 8 | public class MockEmployeeService implements EmployeeService { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/usingprofiles/RealEmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingprofiles; 2 | 3 | import org.springframework.context.annotation.Profile; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @Profile("prod") 8 | public class RealEmployeeService implements EmployeeService { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/jacksonconfiguration/SearchResult.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.jacksonconfiguration; 2 | 3 | import java.util.Date; 4 | import lombok.Data; 5 | 6 | @Data 7 | public class SearchResult { 8 | 9 | private final Date date = new Date(); 10 | private String searchTerm; 11 | private int totalCount; 12 | } 13 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/test/java/com/javabyexamples/java/mapper/orika/generics/basic/Holder.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.generics.basic; 2 | 3 | public class Holder { 4 | 5 | private T value; 6 | 7 | public T getValue() { 8 | return value; 9 | } 10 | 11 | public void setValue(T value) { 12 | this.value = value; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /java-and-test/testng/src/test/resources/suites/dataprovider.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/nonnull/field/Company.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.nonnull.field; 2 | 3 | 4 | import lombok.Getter; 5 | import lombok.NonNull; 6 | import lombok.Setter; 7 | 8 | @Getter 9 | @Setter 10 | public class Company { 11 | 12 | @NonNull 13 | private String location; 14 | } 15 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/requestresponsebody/PersonWithoutXMLAnnotation.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.requestresponsebody; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class PersonWithoutXMLAnnotation { 7 | 8 | private String id; 9 | private String firstName; 10 | private String lastName; 11 | private int age; 12 | } 13 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/constructors/allargs/parent/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.constructors.allargs.parent; 2 | 3 | import lombok.AllArgsConstructor; 4 | 5 | @AllArgsConstructor 6 | public class Employee extends Citizen { 7 | 8 | private String name; 9 | private int salary; 10 | } 11 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/strategy/compareState/iteration1/PrinterWithParameterImpl.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.lets.discuss.strategy.compareState.iteration1; 2 | 3 | public class PrinterWithParameterImpl implements PrinterWithParameter { 4 | 5 | @Override 6 | public void print(String value) { 7 | System.out.println(value); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/conditional/custom/DefaultAuditService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.conditional.custom; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class DefaultAuditService implements AuditService { 7 | 8 | @Override 9 | public void audit() { 10 | // Do audit. 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/eventlistener/RandomTemperature.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.eventlistener; 2 | 3 | import java.util.Random; 4 | 5 | public class RandomTemperature { 6 | 7 | private static final Random random = new Random(); 8 | 9 | public static int getTemperature() { 10 | return random.nextInt(50); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/initializecontext/ApplicationConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.initializecontext; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | @ComponentScan 8 | public class ApplicationConfiguration { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /java-and-test/testng/src/test/resources/suites/annotation_order.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/log/Log4jClient.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.log; 2 | 3 | import lombok.extern.log4j.Log4j; 4 | 5 | @Log4j 6 | public class Log4jClient { 7 | 8 | public static void main(String[] args) { 9 | log.error("Error occurred", new RuntimeException("Planned")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/log/Slf4jClient.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.log; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | @Slf4j 6 | public class Slf4jClient { 7 | 8 | public static void main(String[] args) { 9 | log.error("Error occurred", new RuntimeException("Planned")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/usingprofiles/FastProdEmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingprofiles; 2 | 3 | import org.springframework.context.annotation.Profile; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @Profile("prod & fast") 8 | public class FastProdEmployeeService implements EmployeeService { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/usingprofiles/SlowProdEmployeeService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingprofiles; 2 | 3 | import org.springframework.context.annotation.Profile; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @Profile("prod | slow") 8 | public class SlowProdEmployeeService implements EmployeeService { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/test/java/com/javabyexamples/java/mapper/orika/generics/basic/AnotherHolder.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.generics.basic; 2 | 3 | public class AnotherHolder { 4 | 5 | private T value; 6 | 7 | public T getValue() { 8 | return value; 9 | } 10 | 11 | public void setValue(T value) { 12 | this.value = value; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/log/Log4j2Client.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.log; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | 5 | @Log4j2 6 | public class Log4j2Client { 7 | 8 | public static void main(String[] args) { 9 | log.error("Error occurred", new RuntimeException("Planned")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/log/XSlf4jClient.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.log; 2 | 3 | import lombok.extern.slf4j.XSlf4j; 4 | 5 | @XSlf4j 6 | public class XSlf4jClient { 7 | 8 | public static void main(String[] args) { 9 | log.error("Error occurred", new RuntimeException("Planned")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /maven-and-plugins/property/src/test/java/com/javabyexamples/maven/plugins/property/SetPropertyTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.property; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class SetPropertyTest { 7 | 8 | @Test 9 | public void shouldRun() { 10 | Assert.assertEquals("myValue", System.getProperty("myCustomProperty")); 11 | } 12 | } -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithxml/xstream/PersonCriteria.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithxml.xstream; 2 | 3 | import com.thoughtworks.xstream.annotations.XStreamAlias; 4 | import lombok.Data; 5 | 6 | @Data 7 | @XStreamAlias("criteria") 8 | public class PersonCriteria { 9 | 10 | private String name; 11 | 12 | private String lastName; 13 | } 14 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/builder/defaultvalue/Student.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.builder.defaultvalue; 2 | 3 | import lombok.Builder; 4 | 5 | @Builder 6 | public class Student { 7 | 8 | private String name; 9 | private int age; 10 | @Builder.Default 11 | private String teacher = "Mrs. White"; 12 | } 13 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/importannotation/component/MainConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.importannotation.component; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.context.annotation.Import; 5 | 6 | @Configuration 7 | @Import(ImpressionService.class) 8 | public class MainConfiguration { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/beannaming/AdvancedAuditService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.beannaming; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component("advanced") 7 | @Qualifier("qualifiedAdvanced") 8 | public class AdvancedAuditService implements AuditService { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/equalsandhashcode/inheritance/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.equalsandhashcode.inheritance; 2 | 3 | import lombok.EqualsAndHashCode; 4 | 5 | @EqualsAndHashCode(callSuper = true) 6 | public class Employee extends Citizen { 7 | 8 | private String name; 9 | private int salary; 10 | } 11 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/log/JBossLogClient.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.log; 2 | 3 | import lombok.extern.jbosslog.JBossLog; 4 | 5 | @JBossLog 6 | public class JBossLogClient { 7 | 8 | public static void main(String[] args) { 9 | log.error("Error occurred", new RuntimeException("Planned")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/scopeddependency/beanlookup/ClientService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.scopeddependency.beanlookup; 2 | 3 | public abstract class ClientService { 4 | 5 | public void doWork() { 6 | Timer timer = getTimer(); 7 | timer.start(); 8 | timer.stop(); 9 | } 10 | 11 | protected abstract Timer getTimer(); 12 | } 13 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/jsr330/JsrProviderInjectionPersonService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.jsr330; 2 | 3 | import javax.inject.Inject; 4 | import javax.inject.Named; 5 | import javax.inject.Provider; 6 | 7 | @Named 8 | public class JsrProviderInjectionPersonService { 9 | 10 | @Inject 11 | private Provider personRepositoryProvider; 12 | } 13 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/beanpostprocessor/EnglishGreetingService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.beanpostprocessor; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class EnglishGreetingService implements GreetingService { 7 | 8 | @Override 9 | public void hello() { 10 | System.out.println("Hello"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/beanpostprocessor/FrenchGreetingService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.beanpostprocessor; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class FrenchGreetingService implements GreetingService { 7 | 8 | @Override 9 | public void hello() { 10 | System.out.println("Bonjour"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/mdc/filter/HelloService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.mdc.filter; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Service; 5 | 6 | @Slf4j 7 | @Service 8 | public class HelloService { 9 | 10 | public String sayHello() { 11 | log.info("Entered sayHello"); 12 | return "Hello"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/requestresponsebody/Person.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.requestresponsebody; 2 | 3 | import javax.xml.bind.annotation.XmlRootElement; 4 | import lombok.Data; 5 | 6 | @Data 7 | @XmlRootElement 8 | public class Person { 9 | 10 | private String id; 11 | private String firstName; 12 | private String lastName; 13 | private int age; 14 | } 15 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/getter/fieldlevel/Account.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.getter.fieldlevel; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | public class Account { 7 | 8 | @Getter 9 | @Setter 10 | private String username; 11 | 12 | @Getter 13 | @Setter 14 | private String password; 15 | } 16 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/log/CommonsLogClient.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.log; 2 | 3 | import lombok.extern.apachecommons.CommonsLog; 4 | 5 | @CommonsLog 6 | public class CommonsLogClient { 7 | 8 | public static void main(String[] args) { 9 | log.error("Error occurred", new RuntimeException("Planned")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/log/FLoggerClient.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.log; 2 | 3 | import lombok.extern.flogger.Flogger; 4 | 5 | @Flogger 6 | public class FLoggerClient { 7 | 8 | public static void main(String[] args) { 9 | log.atSevere().withCause(new RuntimeException("Planned")).log("Error occurred"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/exclude/classlevel/Developer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.exclude.classlevel; 2 | 3 | import lombok.ToString; 4 | 5 | @ToString(exclude = {"language", "salary"}) 6 | public class Developer { 7 | 8 | private String name; 9 | private String language; 10 | private int salary; 11 | } 12 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/recursion/Manager.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.recursion; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | 7 | @Getter 8 | @Setter 9 | @ToString 10 | public class Manager { 11 | 12 | private String name; 13 | private Developer subordinate; 14 | } 15 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/conditional/configurationcondition/DefaultAuditService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.conditional.configurationcondition; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class DefaultAuditService implements AuditService { 7 | 8 | @Override 9 | public void audit() { 10 | // Do audit. 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/stereotypes/metaannotation/SimpleGenerator.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.stereotypes.metaannotation; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class SimpleGenerator implements Generator { 7 | 8 | @Override 9 | public void generate() { 10 | System.out.println("Simple generator"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/mdc/interceptor/HelloService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.mdc.interceptor; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Service; 5 | 6 | @Slf4j 7 | @Service 8 | public class HelloService { 9 | 10 | public String sayHello() { 11 | log.info("Entered sayHello"); 12 | return "Hello"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/main/java/com/javabyexamples/java/mapper/orika/basic/PersonHelper.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.basic; 2 | 3 | public class PersonHelper { 4 | 5 | public static Person getPerson() { 6 | final Person person = new Person(); 7 | person.setFirstName("john"); 8 | person.setLastName("doe"); 9 | person.setAge(25); 10 | return person; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /maven-and-plugins/surefire/src/test/resources/debug-commands.txt: -------------------------------------------------------------------------------- 1 | mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8090 -Xnoagent -Djava.compiler=NONE" test 2 | mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8090" test 3 | mvn -Dmaven.surefire.debug test 4 | MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8090" mvn -DforkCount=0 test -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/initializecontext/service/DefaultGreetService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.initializecontext.service; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class DefaultGreetService implements GreetService { 7 | 8 | @Override 9 | public void greet() { 10 | System.out.println("Greetings..."); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithxml/xstream/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithxml.xstream; 2 | 3 | import com.thoughtworks.xstream.annotations.XStreamAlias; 4 | import lombok.Data; 5 | 6 | @Data 7 | @XStreamAlias("details") 8 | public class PersonDetails { 9 | 10 | private String name; 11 | 12 | private String lastName; 13 | 14 | private int age; 15 | } 16 | -------------------------------------------------------------------------------- /spring-mvc-2/src/main/java/com/javabyexamples/spring/mvc2/apache/PingController.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc2.apache; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class PingController { 8 | 9 | @GetMapping("/ping") 10 | public String ping() { 11 | return "OK"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-and-test/testng/src/test/java/com/javabyexamples/java/test/testng/general/GroupTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.testng.general; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | public class GroupTest { 6 | 7 | @Test(groups = "football") 8 | public void shouldPlayFootball() { 9 | 10 | } 11 | 12 | @Test(groups = "basketball") 13 | public void shouldPlayBasketball() { 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/log/LogClient.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.log; 2 | 3 | import java.util.logging.Level; 4 | import lombok.extern.java.Log; 5 | 6 | @Log 7 | public class LogClient { 8 | 9 | public static void main(String[] args) { 10 | log.log(Level.SEVERE, "Error occurred", new RuntimeException("Planned")); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/include/classlevel/Developer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.include.classlevel; 2 | 3 | import lombok.ToString; 4 | 5 | @ToString(of = {"name", "experienceInYears"}) 6 | public class Developer { 7 | 8 | private String name; 9 | private String language; 10 | private int experienceInYears; 11 | } 12 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/builder/singular/Student.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.builder.singular; 2 | 3 | import java.util.Set; 4 | import lombok.Builder; 5 | import lombok.Singular; 6 | 7 | @Builder 8 | public class Student { 9 | 10 | private String name; 11 | private int age; 12 | @Singular 13 | private Set lessons; 14 | } 15 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/equalsandhashcode/include/classlevel/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.equalsandhashcode.include.classlevel; 2 | 3 | import lombok.EqualsAndHashCode; 4 | 5 | @EqualsAndHashCode(of = {"name", "age"}) 6 | public class Employee { 7 | 8 | private String name; 9 | private int age; 10 | private int salary; 11 | } 12 | -------------------------------------------------------------------------------- /maven-and-plugins/surefire/src/test/java/com/javabyexamples/maven/plugins/surefire/SampleTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.surefire; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | public class SampleTest { 8 | 9 | private Person person = new Person(); 10 | 11 | @Test 12 | public void shouldRun() { 13 | assertEquals("Running", person.run()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/disambiguatingbeans/LongNumberService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.disambiguatingbeans; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class LongNumberService implements NumberService { 7 | 8 | @Override 9 | public Long get() { 10 | System.out.println("Returning long"); 11 | return 1L; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/suffixmatch/SuffixMatchController.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.suffixmatch; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | 6 | @Controller 7 | public class SuffixMatchController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "hello"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-and-test/testng/src/test/resources/suites/parameter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/equalsandhashcode/exclude/classlevel/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.equalsandhashcode.exclude.classlevel; 2 | 3 | import lombok.EqualsAndHashCode; 4 | 5 | @EqualsAndHashCode(exclude = {"age", "salary"}) 6 | public class Employee { 7 | 8 | private String name; 9 | private int age; 10 | private int salary; 11 | } 12 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/exclude/fieldlevel/Developer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.exclude.fieldlevel; 2 | 3 | import lombok.ToString; 4 | 5 | @ToString 6 | public class Developer { 7 | 8 | private String name; 9 | @ToString.Exclude 10 | private String language; 11 | @ToString.Exclude 12 | private int salary; 13 | } 14 | -------------------------------------------------------------------------------- /maven-and-plugins/buildhelper/imported/test/java/com/isa/maven/plugins/buildhelper/JobTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.buildhelper; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class JobTest { 7 | 8 | private Job job = new Job(); 9 | 10 | @Test 11 | public void shouldWork(){ 12 | String result = job.work(); 13 | 14 | Assert.assertEquals("working", result); 15 | } 16 | } -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/conditional/custom/DummyAuditService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.conditional.custom; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | @ConditionalOnMissingService(AuditService.class) 7 | public class DummyAuditService implements AuditService { 8 | 9 | @Override 10 | public void audit() { 11 | // Do nothing. 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/beandefinition/DefaultService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.beandefinition; 2 | 3 | public class DefaultService implements ServiceOne, ServiceTwo { 4 | 5 | @Override 6 | public void one() { 7 | System.out.println("One"); 8 | } 9 | 10 | @Override 11 | public void two() { 12 | System.out.println("Two."); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/customqualifier/V1PersonService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.customqualifier; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | @Version1 7 | public class V1PersonService implements PersonService { 8 | 9 | @Override 10 | public void hello() { 11 | System.out.println("Hello from: " + getClass().getSimpleName()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/customqualifier/V2PersonService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.customqualifier; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | @Version2 7 | public class V2PersonService implements PersonService { 8 | 9 | @Override 10 | public void hello() { 11 | System.out.println("Hello from: " + getClass().getSimpleName()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-and-mapper/mapstruct/src/main/java/com/javabyexamples/java/mapper/mapstruct/collection/Student.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.mapstruct.collection; 2 | 3 | import java.util.List; 4 | 5 | public class Student { 6 | 7 | private List exams; 8 | 9 | public List getExams() { 10 | return exams; 11 | } 12 | 13 | public void setExams(List exams) { 14 | this.exams = exams; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/importannotation/selector/ImpressionService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.importannotation.selector; 2 | 3 | public class ImpressionService { 4 | 5 | private final Counter counter; 6 | 7 | public ImpressionService(Counter counter) { 8 | this.counter = counter; 9 | } 10 | 11 | public void countImpression() { 12 | counter.count(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/disambiguatingbeans/SimpleCalculationService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.disambiguatingbeans; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component("simple") 6 | public class SimpleCalculationService implements CalculationService { 7 | 8 | @Override 9 | public void calculate() { 10 | System.out.println("Simple calculation"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/async/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.async; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/headers/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.headers; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-2/src/main/java/com/javabyexamples/spring/mvc2/apache/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc2.apache; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-2/src/main/java/com/javabyexamples/spring/mvc2/filter/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc2.filter; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/basic/DeveloperDelomboked.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.basic; 2 | 3 | public class DeveloperDelomboked { 4 | 5 | private String name; 6 | private String language; 7 | 8 | public String toString() { 9 | return "DeveloperDelomboked(name=" + this.name + ", language=" + this.language + ")"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-and-test/mockito/src/test/java/com/javabyexamples/java/test/mockito/model/Person.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.mockito.model; 2 | 3 | public class Person { 4 | 5 | private String name; 6 | 7 | public Person(String name) { 8 | this.name = name; 9 | } 10 | 11 | public String getName() { 12 | return name; 13 | } 14 | 15 | public void setName(String name) { 16 | this.name = name; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /java-and-test/testng/src/test/java/com/javabyexamples/java/test/testng/general/ParametersTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.testng.general; 2 | 3 | import org.testng.annotations.Parameters; 4 | import org.testng.annotations.Test; 5 | 6 | public class ParametersTest { 7 | 8 | @Test 9 | @Parameters("name") 10 | public void shouldRun(String name) { 11 | System.out.println("Running with parameter: " + name); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/equalsandhashcode/recursion/Manager.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.equalsandhashcode.recursion; 2 | 3 | import lombok.EqualsAndHashCode; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | @Getter 8 | @Setter 9 | @EqualsAndHashCode 10 | public class Manager { 11 | 12 | private String name; 13 | private Employee subordinate; 14 | } 15 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/strategy/compareState/iteration2/BlackListWordFilter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.lets.discuss.strategy.compareState.iteration2; 2 | 3 | import java.util.List; 4 | 5 | public class BlackListWordFilter implements WordFilter { 6 | 7 | @Override 8 | public boolean filter(String word, List whiteList, List blackList) { 9 | return !blackList.contains(word); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/strategy/compareState/iteration2/WhiteListWordFilter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.lets.discuss.strategy.compareState.iteration2; 2 | 3 | import java.util.List; 4 | 5 | public class WhiteListWordFilter implements WordFilter { 6 | 7 | @Override 8 | public boolean filter(String word, List whiteList, List blackList) { 9 | return whiteList.contains(word); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/importannotation/configuration/ImpressionService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.importannotation.configuration; 2 | 3 | public class ImpressionService { 4 | 5 | private final Counter counter; 6 | 7 | public ImpressionService(Counter counter) { 8 | this.counter = counter; 9 | } 10 | 11 | public void countImpression(){ 12 | counter.count(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/importannotation/metaannotation/ImpressionService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.importannotation.metaannotation; 2 | 3 | public class ImpressionService { 4 | 5 | private final Counter counter; 6 | 7 | public ImpressionService(Counter counter) { 8 | this.counter = counter; 9 | } 10 | 11 | public void countImpression() { 12 | counter.count(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/interceptor/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.interceptor; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithjson/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithjson; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/suffixmatch/SuffixMatchRestController.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.suffixmatch; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class SuffixMatchRestController { 8 | 9 | @GetMapping("/bye") 10 | public String hello() { 11 | return "bye"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/suffixmatch/api/HealthRestController.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.suffixmatch.api; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HealthRestController { 8 | 9 | @GetMapping("/health") 10 | public String health() { 11 | return "OK"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-and-mapper/mapstruct/src/main/java/com/javabyexamples/java/mapper/mapstruct/collection/StudentDto.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.mapstruct.collection; 2 | 3 | import java.util.List; 4 | 5 | public class StudentDto { 6 | 7 | private List exams; 8 | 9 | public List getExams() { 10 | return exams; 11 | } 12 | 13 | public void setExams(List exams) { 14 | this.exams = exams; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/getter/configure/Account.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.getter.configure; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.experimental.Accessors; 6 | 7 | @Getter 8 | @Setter 9 | @Accessors(fluent = true, chain = true) 10 | public class Account { 11 | 12 | private String username; 13 | private String password; 14 | } 15 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/strategy/compareState/iteration2/enhancement/BlackListWordFilter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.lets.discuss.strategy.compareState.iteration2.enhancement; 2 | 3 | public class BlackListWordFilter implements WordFilter { 4 | 5 | @Override 6 | public boolean filter(String word, WordFilterOptions wordFilterOptions) { 7 | return !wordFilterOptions.getBlackList().contains(word); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/currentrequest/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.currentrequest; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/responsestatus/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.responsestatus; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/strategy/compareState/iteration2/enhancement/WhiteListWordFilter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.lets.discuss.strategy.compareState.iteration2.enhancement; 2 | 3 | 4 | public class WhiteListWordFilter implements WordFilter { 5 | 6 | @Override 7 | public boolean filter(String word, WordFilterOptions wordFilterOptions) { 8 | return wordFilterOptions.getWhiteList().contains(word); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/asyncinterceptor/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.asyncinterceptor; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/requestmapping/paths/Exam.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.requestmapping.paths; 2 | 3 | import java.util.Date; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class Exam { 12 | 13 | private String name; 14 | private String department; 15 | private Date date; 16 | } 17 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restreturnvalues/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restreturnvalues; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithxml/jaxb/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithxml.jaxb; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/shortcutmapping/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.shortcutmapping; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/templatelocation/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.templatelocation; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/constructors/requiredargs/EmployeeDelomboked.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.constructors.requiredargs; 2 | 3 | public class EmployeeDelomboked { 4 | 5 | private final String name; 6 | private int salary; 7 | 8 | @java.beans.ConstructorProperties({"name"}) 9 | public EmployeeDelomboked(String name) { 10 | this.name = name; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/strategy/compareState/iteration1/PrinterImpl.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.lets.discuss.strategy.compareState.iteration1; 2 | 3 | public class PrinterImpl implements Printer { 4 | 5 | private final String value; 6 | 7 | public PrinterImpl(String value) { 8 | this.value = value; 9 | } 10 | 11 | @Override 12 | public void print() { 13 | System.out.println(value); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/importannotation/configuration/CounterConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.importannotation.configuration; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | public class CounterConfiguration { 8 | 9 | @Bean 10 | public Counter counter() { 11 | return new Counter(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/callableinterceptor/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.callableinterceptor; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/deferredinterceptor/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.deferredinterceptor; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/requestresponsebody/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.requestresponsebody; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithxml/builtin/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithxml.builtin; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithxml/castor/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithxml.castor; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithxml/xstream/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithxml.xstream; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/serverconfiguration/properties/PingController.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.serverconfiguration.properties; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class PingController { 8 | 9 | @GetMapping("/ping") 10 | public String ping() { 11 | return "OK"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-mvc-2/src/main/java/com/javabyexamples/spring/mvc2/serverconfiguration/properties/PingController.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc2.serverconfiguration.properties; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class PingController { 8 | 9 | @GetMapping("/ping") 10 | public String ping() { 11 | return "OK"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/Mutable.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.TYPE) 10 | public @interface Mutable { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /java-and-mapper/mapstruct/src/main/java/com/javabyexamples/java/mapper/mapstruct/collection/primitive/ListMapper.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.mapstruct.collection.primitive; 2 | 3 | import java.util.List; 4 | import org.mapstruct.Mapper; 5 | import org.mapstruct.factory.Mappers; 6 | 7 | @Mapper 8 | public interface ListMapper { 9 | 10 | ListMapper INSTANCE = Mappers.getMapper(ListMapper.class); 11 | 12 | List map(List grades); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/main/java/com/javabyexamples/java/mapper/orika/mappingwithcollections/Family.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.mappingwithcollections; 2 | 3 | import java.util.List; 4 | 5 | public class Family { 6 | 7 | private List parents; 8 | 9 | public List getParents() { 10 | return parents; 11 | } 12 | 13 | public void setParents(List parents) { 14 | this.parents = parents; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /java-and-test/junitrule/src/test/java/com/javabyexamples/java/test/junit/rule/custom/monitor/MonitorRuleTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.junit.rule.custom.monitor; 2 | 3 | import org.junit.Rule; 4 | import org.junit.Test; 5 | 6 | public class MonitorRuleTest { 7 | 8 | @Rule 9 | public MonitorRule monitorRule = new MonitorRule(); 10 | 11 | @Test 12 | public void shouldMonitor() { 13 | System.out.println("Actual test code..."); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/nonnull/EmployeeServiceDelomboked.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.nonnull; 2 | 3 | public class EmployeeServiceDelomboked { 4 | 5 | public void increaseSalary(String name) { 6 | if (name == null) { 7 | throw new NullPointerException("name is marked @NonNull but is null"); 8 | } 9 | 10 | System.out.println(name); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/exclude/classlevel/DeveloperDelomboked.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.exclude.classlevel; 2 | 3 | public class DeveloperDelomboked { 4 | 5 | private String name; 6 | private String language; 7 | private int salary; 8 | 9 | public String toString() { 10 | return "DeveloperDelomboked(name=" + this.name + ")"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/exclude/fieldlevel/DeveloperDelomboked.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.exclude.fieldlevel; 2 | 3 | public class DeveloperDelomboked { 4 | 5 | private String name; 6 | private String language; 7 | private int salary; 8 | 9 | public String toString() { 10 | return "DeveloperDelomboked(name=" + this.name + ")"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/recursion/Developer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.recursion; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | 7 | @Getter 8 | @Setter 9 | @ToString(exclude = "manager") 10 | public class Developer { 11 | 12 | private String name; 13 | private String language; 14 | private Manager manager; 15 | } 16 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentscan/scan/DefaultComponentScanConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentscan.scan; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | @ComponentScan(basePackages = "com.javabyexamples.spring.core.componentscan.level1") 8 | public class DefaultComponentScanConfiguration { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/importannotation/metaannotation/CounterConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.importannotation.metaannotation; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | public class CounterConfiguration { 8 | 9 | @Bean 10 | public Counter counter() { 11 | return new Counter(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/importannotation/selector/ProdCounterConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.importannotation.selector; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | public class ProdCounterConfiguration { 8 | 9 | @Bean 10 | public Counter counter() { 11 | return new Counter("prod"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/CanLeak.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.METHOD) 10 | public @interface CanLeak { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/Delegated.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.FIELD) 10 | public @interface Delegated { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/Delegating.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.TYPE) 10 | public @interface Delegating { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/Immutable.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.TYPE) 10 | public @interface Immutable { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/StaleData.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.TYPE) 10 | public @interface StaleData { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/ThreadSafe.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.TYPE) 10 | public @interface ThreadSafe { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/include/fieldlevel/Developer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.include.fieldlevel; 2 | 3 | import lombok.ToString; 4 | 5 | @ToString(onlyExplicitlyIncluded = true) 6 | public class Developer { 7 | 8 | @ToString.Include 9 | private String name; 10 | private String language; 11 | @ToString.Include 12 | private int experienceInYears; 13 | } 14 | -------------------------------------------------------------------------------- /java-core-1/src/main/java/com/javabyexamples/java/core/classloader/dynamic/DefaultCounter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.core.classloader.dynamic; 2 | 3 | public class DefaultCounter implements Counter { 4 | 5 | private int counter; 6 | 7 | public String message() { 8 | return "Version 2"; 9 | } 10 | 11 | public int plusPlus() { 12 | return counter++; 13 | } 14 | 15 | public int counter() { 16 | return counter; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/importannotation/selector/LocalCounterConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.importannotation.selector; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | public class LocalCounterConfiguration { 8 | 9 | @Bean 10 | public Counter counter() { 11 | return new Counter("local"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-mvc-2/src/main/java/com/javabyexamples/spring/mvc2/readrequestbody/caching/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc2.readrequestbody.caching; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/NonStaleData.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.TYPE) 10 | public @interface NonStaleData { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /java-and-test/testng/src/test/java/com/javabyexamples/java/test/testng/general/DependsOnTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.testng.general; 2 | 3 | import org.testng.annotations.Test; 4 | 5 | public class DependsOnTest { 6 | 7 | @Test 8 | public void init() { 9 | System.out.println("Init"); 10 | } 11 | 12 | @Test(dependsOnMethods = "init") 13 | public void shouldRunAfterInit() { 14 | System.out.println("Now I can run"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/equalsandhashcode/exclude/fieldlevel/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.equalsandhashcode.exclude.fieldlevel; 2 | 3 | import lombok.EqualsAndHashCode; 4 | 5 | @EqualsAndHashCode 6 | public class Employee { 7 | 8 | private String name; 9 | @EqualsAndHashCode.Exclude 10 | private int age; 11 | @EqualsAndHashCode.Exclude 12 | private int salary; 13 | } 14 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/javaconfig/ClassService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.javaconfig; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class ClassService { 7 | 8 | public List getStudents() { 9 | List students = new ArrayList(); 10 | students.add(new Student("John")); 11 | students.add(new Student("Sarah")); 12 | return students; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/interceptor/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.interceptor; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | System.out.println("hello()"); 12 | return "Hello"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/requestresponsebodyadvice/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.requestresponsebodyadvice; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/serverconfiguration/tomcat/customizer/PingController.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.serverconfiguration.tomcat.customizer; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class PingController { 8 | 9 | @GetMapping("/ping") 10 | public String ping() { 11 | return "OK"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-mvc-2/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 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 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-mvc-2/src/main/java/com/javabyexamples/spring/mvc2/serverconfiguration/tomcat/customizer/PingController.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc2.serverconfiguration.tomcat.customizer; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class PingController { 8 | 9 | @GetMapping("/ping") 10 | public String ping() { 11 | return "OK"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/InvariantHolds.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.METHOD) 10 | public @interface InvariantHolds { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/NotThreadSafe.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.TYPE) 10 | public @interface NotThreadSafe { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/ThreadConfined.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.FIELD) 10 | public @interface ThreadConfined { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/test/java/com/javabyexamples/java/mapper/orika/generics/basic/PersonHolder.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.generics.basic; 2 | 3 | import com.javabyexamples.java.mapper.orika.generics.collections.Person; 4 | 5 | public class PersonHolder { 6 | 7 | private Person value; 8 | 9 | public Person getValue() { 10 | return value; 11 | } 12 | 13 | public void setValue(Person value) { 14 | this.value = value; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/importannotation/selector/Counter.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.importannotation.selector; 2 | 3 | public class Counter { 4 | 5 | private final String environment; 6 | private int current = 0; 7 | 8 | public Counter(String environment) { 9 | this.environment = environment; 10 | } 11 | 12 | public void count() { 13 | System.out.println(environment + ": " + current++); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/jacksonconfiguration/explicit/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.jacksonconfiguration.explicit; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/usingautowired/wiremultiple/LocalGoodService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingautowired.wiremultiple; 2 | 3 | import org.springframework.core.annotation.Order; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @Order(0) 8 | public class LocalGoodService implements GoodService { 9 | 10 | @Override 11 | public void buy() { 12 | System.out.println("Buying local goods."); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/jacksonconfiguration/customizer/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.jacksonconfiguration.customizer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/InvariantCanBreak.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.METHOD) 10 | public @interface InvariantCanBreak { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/equalsandhashcode/recursion/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.equalsandhashcode.recursion; 2 | 3 | import lombok.EqualsAndHashCode; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | @Getter 8 | @Setter 9 | @EqualsAndHashCode(exclude = "manager") 10 | public class Employee { 11 | 12 | private String name; 13 | private int salary; 14 | private Manager manager; 15 | } 16 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/setter/AccountDelomboked.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.setter; 2 | 3 | public class AccountDelomboked { 4 | 5 | private String username; 6 | private String password; 7 | 8 | public void setUsername(String username) { 9 | this.username = username; 10 | } 11 | 12 | public void setPassword(String password) { 13 | this.password = password; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lets.discuss/src/main/java/com/javabyexamples/lets/discuss/builder/compareToFluent/fluent/ClientMain.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.lets.discuss.builder.compareToFluent.fluent; 2 | 3 | 4 | public class ClientMain { 5 | 6 | public static void main(String[] args) { 7 | new Employee().firstName("John") 8 | .lastName("Doe") 9 | .department("Accounting") 10 | .startTime(10) 11 | .endTime(18); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/jsr330/JsrSetterInjectionPersonService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.jsr330; 2 | 3 | import javax.inject.Inject; 4 | import javax.inject.Named; 5 | 6 | @Named 7 | public class JsrSetterInjectionPersonService { 8 | 9 | private PersonRepository personRepository; 10 | 11 | @Inject 12 | public void setPersonRepository(PersonRepository personRepository) { 13 | this.personRepository = personRepository; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-mvc-1/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 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 | 30 | ### VS Code ### 31 | .vscode/ 32 | 33 | logs 34 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/serverconfiguration/tomcat/factorycustomizer/PingController.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.serverconfiguration.tomcat.factorycustomizer; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class PingController { 8 | 9 | @GetMapping("/ping") 10 | public String ping() { 11 | return "OK"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-mvc-2/src/main/java/com/javabyexamples/spring/mvc2/serverconfiguration/tomcat/factorycustomizer/PingController.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc2.serverconfiguration.tomcat.factorycustomizer; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class PingController { 8 | 9 | @GetMapping("/ping") 10 | public String ping() { 11 | return "OK"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/test/java/com/javabyexamples/java/mapper/orika/generics/basic/AnotherPersonHolder.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.generics.basic; 2 | 3 | import com.javabyexamples.java.mapper.orika.generics.collections.Person; 4 | 5 | public class AnotherPersonHolder { 6 | 7 | private Person value; 8 | 9 | public Person getValue() { 10 | return value; 11 | } 12 | 13 | public void setValue(Person value) { 14 | this.value = value; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /java-basics/jar/executable-jar/src/main/java/com/javabyexamples/java/jar/Greeting.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.jar; 2 | 3 | public class Greeting { 4 | 5 | public static void main(String[] args) { 6 | if (args.length != 2) { 7 | throw new IllegalStateException("Please enter your name and city."); 8 | } 9 | 10 | final String name = args[0]; 11 | final String city = args[1]; 12 | System.out.printf("Hello %s from %s%n", name, city); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/conditional/condition/DefaultAuditService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.conditional.condition; 2 | 3 | import org.springframework.context.annotation.Conditional; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @Conditional(AuditEnabledCondition.class) 8 | public class DefaultAuditService implements AuditService { 9 | 10 | @Override 11 | public void audit() { 12 | // Do audit... 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/usingautowired/wiremultiple/ImportedGoodService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingautowired.wiremultiple; 2 | 3 | import org.springframework.core.annotation.Order; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @Order(1) 8 | public class ImportedGoodService implements GoodService { 9 | 10 | @Override 11 | public void buy() { 12 | System.out.println("Buying imported goods."); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/serverconfiguration/tomcat/customizer/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.serverconfiguration.tomcat.customizer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/test/java/com/javabyexamples/spring/mvc1/controller/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.controller; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTest { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-mvc-2/src/main/java/com/javabyexamples/spring/mvc2/serverconfiguration/tomcat/customizer/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc2.serverconfiguration.tomcat.customizer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/CannotLeak.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) 10 | public @interface CannotLeak { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/test/java/com/javabyexamples/java/mapper/orika/generics/collections/Group.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.generics.collections; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Group

{ 7 | 8 | private List

members = new ArrayList<>(); 9 | 10 | public List

getMembers() { 11 | return members; 12 | } 13 | 14 | public void setMembers(List

members) { 15 | this.members = members; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/test/java/com/javabyexamples/java/mapper/orika/generics/collections/Inventory.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.generics.collections; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class Inventory { 7 | 8 | private Map data = new HashMap<>(); 9 | 10 | public Map getData() { 11 | return data; 12 | } 13 | 14 | public void setData(Map data) { 15 | this.data = data; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/constructors/noargs/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.constructors.noargs; 2 | 3 | import lombok.NoArgsConstructor; 4 | 5 | @NoArgsConstructor 6 | public class Employee { 7 | 8 | private String name; 9 | private int salary; 10 | } 11 | 12 | @NoArgsConstructor(staticName = "of") 13 | class Department { 14 | 15 | private String location; 16 | private String employeeNumber; 17 | } 18 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/lifecycle/CustomMethodsService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.lifecycle; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class CustomMethodsService { 7 | 8 | public void initialize() { 9 | System.out.println("Initializing " + getClass().getSimpleName()); 10 | } 11 | 12 | public void destroy() { 13 | System.out.println("Destroying " + getClass().getSimpleName()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/StopWatch.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common; 2 | 3 | public class StopWatch { 4 | 5 | private long start; 6 | 7 | public void start() { 8 | start = System.currentTimeMillis(); 9 | } 10 | 11 | public long elapsedTime() { 12 | if (start == 0) { 13 | return 0; 14 | } 15 | 16 | return System.currentTimeMillis() - start; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/test/java/com/javabyexamples/java/mapper/orika/generics/collections/GroupDto.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.generics.collections; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class GroupDto

{ 7 | 8 | private List

members = new ArrayList<>(); 9 | 10 | public List

getMembers() { 11 | return members; 12 | } 13 | 14 | public void setMembers(List

members) { 15 | this.members = members; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/test/java/com/javabyexamples/java/mapper/orika/generics/collections/InventoryDto.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.generics.collections; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class InventoryDto { 7 | 8 | private Map data = new HashMap<>(); 9 | 10 | public Map getData() { 11 | return data; 12 | } 13 | 14 | public void setData(Map data) { 15 | this.data = data; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/constructors/allargs/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.constructors.allargs; 2 | 3 | import lombok.AllArgsConstructor; 4 | 5 | @AllArgsConstructor 6 | public class Employee { 7 | 8 | private String name; 9 | private int salary; 10 | } 11 | 12 | @AllArgsConstructor(staticName = "of") 13 | class Department { 14 | 15 | private String location; 16 | private String employeeNumber; 17 | } 18 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/equalsandhashcode/include/fieldlevel/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.equalsandhashcode.include.fieldlevel; 2 | 3 | import lombok.EqualsAndHashCode; 4 | 5 | @EqualsAndHashCode(onlyExplicitlyIncluded = true) 6 | public class Employee { 7 | 8 | @EqualsAndHashCode.Include 9 | private String name; 10 | @EqualsAndHashCode.Include 11 | private int age; 12 | private int salary; 13 | } 14 | -------------------------------------------------------------------------------- /spring-core-3/src/main/java/com/javabyexamples/spring/core/propertysource/useannotation/PropertySourceConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.propertysource.useannotation; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.PropertySource; 6 | 7 | @Slf4j 8 | @Configuration 9 | @PropertySource("classpath:propertysource/sample.properties") 10 | public class PropertySourceConfiguration { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/disambiguatingbeans/AdvancedCalculationService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.disambiguatingbeans; 2 | 3 | import org.springframework.context.annotation.Primary; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @Primary 8 | public class AdvancedCalculationService implements CalculationService { 9 | 10 | @Override 11 | public void calculate() { 12 | System.out.println("Advanced calculation"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/common/annotation/GuardedBy.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.FIELD) 10 | public @interface GuardedBy { 11 | 12 | String value() default ""; 13 | } 14 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/composing/delegation/single/ImmutablePoint.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.composing.delegation.single; 2 | 3 | import com.javabyexamples.java.concurrency.common.annotation.Immutable; 4 | 5 | @Immutable 6 | public class ImmutablePoint { 7 | 8 | public final int x; 9 | public final int y; 10 | 11 | public ImmutablePoint(int x, int y) { 12 | this.x = x; 13 | this.y = y; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /java-and-test/wiremock/src/main/java/com/javabyexamples/java/test/wiremock/server/NoOpNotifier.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.wiremock.server; 2 | 3 | import com.github.tomakehurst.wiremock.common.Notifier; 4 | 5 | public class NoOpNotifier implements Notifier { 6 | 7 | @Override 8 | public void info(String message) { 9 | } 10 | 11 | @Override 12 | public void error(String message) { 13 | } 14 | 15 | @Override 16 | public void error(String message, Throwable t) { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/include/methodlevel/Developer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.include.methodlevel; 2 | 3 | import lombok.ToString; 4 | 5 | @ToString 6 | public class Developer { 7 | 8 | private String name; 9 | private String language; 10 | private int experienceInYears; 11 | 12 | @ToString.Include 13 | public boolean isJunior() { 14 | return experienceInYears < 2; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-core-2/src/test/java/com/javabyexamples/spring/core/jsr330/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.jsr330; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @ContextConfiguration(classes = Application.class) 10 | public class ApplicationTest { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | } -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/requestmapping/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.requestmapping; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | new SpringApplicationBuilder().main(Application.class).profiles("requestmapping").run(args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/serverconfiguration/tomcat/factorycustomizer/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.serverconfiguration.tomcat.factorycustomizer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-2/src/main/java/com/javabyexamples/spring/mvc2/requestlogging/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc2.requestlogging; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | new SpringApplicationBuilder().main(Application.class).profiles("requestlogging").run(args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-2/src/main/java/com/javabyexamples/spring/mvc2/serverconfiguration/tomcat/factorycustomizer/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc2.serverconfiguration.tomcat.factorycustomizer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-and-test/junitrule/README.md: -------------------------------------------------------------------------------- 1 | # JUnit Rules 2 | 3 | Some examples are covered in the following blog posts: 4 | 5 | - http://www.javabyexamples.com/structure-of-junit-test-rule/ 6 | - http://www.javabyexamples.com/set-timeout-for-tests-with-junit/ 7 | - http://www.javabyexamples.com/built-in-junit-test-rules/ 8 | - http://www.javabyexamples.com/how-to-verify-exceptions-with-junit/ 9 | - http://www.javabyexamples.com/conditional-ignore-with-junit-test-rule/ 10 | - http://www.javabyexamples.com/monitor-tests-with-junit-test-rule/ 11 | -------------------------------------------------------------------------------- /java-and-test/testng/src/test/resources/suites/group_football.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/lifecycle/DefaultPersonService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.lifecycle; 2 | 3 | public class DefaultPersonService implements PersonService { 4 | 5 | public void init() { 6 | System.out.println("Initializing."); 7 | } 8 | 9 | @Override 10 | public void work() { 11 | System.out.println("Working."); 12 | } 13 | 14 | public void stop() { 15 | System.out.println("Stopping."); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-core-3/src/test/java/com/javabyexamples/spring/core/spel/rootobject/Person.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.spel.rootobject; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @Builder 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | public class Person { 13 | 14 | private String name; 15 | private String lastName; 16 | private boolean married; 17 | private Address address = new Address(); 18 | } 19 | -------------------------------------------------------------------------------- /java-and-test/testng/src/test/resources/suites/group_basketball.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/value/accessmodifier/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.value.accessmodifier; 2 | 3 | import lombok.Value; 4 | import lombok.experimental.NonFinal; 5 | import lombok.experimental.PackagePrivate; 6 | 7 | @Value 8 | @NonFinal 9 | public class Employee { 10 | 11 | @NonFinal 12 | @PackagePrivate 13 | private String name; 14 | 15 | @NonFinal 16 | @PackagePrivate 17 | private int salary; 18 | } 19 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/conditional/configurationcondition/DummyAuditService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.conditional.configurationcondition; 2 | 3 | import org.springframework.context.annotation.Conditional; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @Conditional(MissingServiceCondition.class) 8 | public class DummyAuditService implements AuditService { 9 | 10 | @Override 11 | public void audit() { 12 | // Do nothing. 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/jsr330/JsrConstructorInjectionPersonService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.jsr330; 2 | 3 | import javax.inject.Inject; 4 | import javax.inject.Named; 5 | 6 | @Named 7 | public class JsrConstructorInjectionPersonService { 8 | 9 | private final PersonRepository personRepository; 10 | 11 | @Inject 12 | public JsrConstructorInjectionPersonService(PersonRepository personRepository) { 13 | this.personRepository = personRepository; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-core/src/test/java/com/javabyexamples/spring/core/lifecycle/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.lifecycle; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @ContextConfiguration(classes = Application.class) 10 | public class ApplicationTest { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/test/java/com/javabyexamples/java/mapper/orika/generics/collections/PersonGroup.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.generics.collections; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class PersonGroup { 7 | 8 | private List members = new ArrayList<>(); 9 | 10 | public List getMembers() { 11 | return members; 12 | } 13 | 14 | public void setMembers(List members) { 15 | this.members = members; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/data/EmployeeExpanded.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.data; 2 | 3 | import lombok.EqualsAndHashCode; 4 | import lombok.Getter; 5 | import lombok.RequiredArgsConstructor; 6 | import lombok.Setter; 7 | import lombok.ToString; 8 | 9 | @Getter 10 | @Setter 11 | @RequiredArgsConstructor 12 | @ToString 13 | @EqualsAndHashCode 14 | public class EmployeeExpanded { 15 | 16 | private String name; 17 | private int salary; 18 | } 19 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/equalsandhashcode/include/methodlevel/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.equalsandhashcode.include.methodlevel; 2 | 3 | import lombok.EqualsAndHashCode; 4 | 5 | @EqualsAndHashCode 6 | public class Employee { 7 | 8 | private String name; 9 | private int age; 10 | private int salary; 11 | 12 | @EqualsAndHashCode.Include 13 | public boolean canDrink() { 14 | return age > 18; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /maven-and-plugins/failsafe/src/test/java/com/javabyexamples/maven/plugins/failsafe/groups/Person2IT.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.failsafe.groups; 2 | 3 | import com.javabyexamples.maven.plugins.failsafe.Person; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | 7 | public class Person2IT { 8 | 9 | private Person person = new Person(); 10 | 11 | @Test 12 | public void shouldSayHello() { 13 | String result = person.sayHello(); 14 | 15 | Assert.assertEquals("Hello", result); 16 | } 17 | } -------------------------------------------------------------------------------- /maven-and-plugins/surefire/src/test/java/com/javabyexamples/maven/plugins/surefire/groups/RegularPersonTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.surefire.groups; 2 | 3 | import com.javabyexamples.maven.plugins.surefire.Person; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | 7 | public class RegularPersonTest { 8 | 9 | private Person person = new Person(); 10 | 11 | @Test 12 | public void run() { 13 | String result = person.run(); 14 | 15 | Assert.assertEquals("Running", result); 16 | } 17 | } -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/jsr330/qualify/DepartmentService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.jsr330.qualify; 2 | 3 | import javax.inject.Inject; 4 | import javax.inject.Named; 5 | 6 | @Named 7 | public class DepartmentService { 8 | 9 | private final DepartmentRepository departmentRepository; 10 | 11 | @Inject 12 | public DepartmentService(@Named("department") DepartmentRepository departmentRepository) { 13 | this.departmentRepository = departmentRepository; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-core/src/test/java/com/javabyexamples/spring/core/beannaming/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.beannaming; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @ContextConfiguration(classes = Application.class) 10 | public class ApplicationTest { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-core/src/test/java/com/javabyexamples/spring/core/javaconfig/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.javaconfig; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @ContextConfiguration(classes = Application.class) 10 | public class ApplicationTest { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-core/src/test/java/com/javabyexamples/spring/core/stereotypes/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.stereotypes; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @ContextConfiguration(classes = Application.class) 10 | public class ApplicationTest { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /java-and-mapper/mapstruct/src/test/java/com/javabyexamples/java/mapper/mapstruct/TestHelper.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.mapstruct; 2 | 3 | public class TestHelper { 4 | 5 | public static Student getStudent(){ 6 | final Student student = new Student("Jack", "Jones"); 7 | final School school = new School(); 8 | school.setName("Little Bees"); 9 | school.setCity("London"); 10 | school.setStudentCount(100); 11 | student.setSchool(school); 12 | return student; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/tostring/recursion/RecursionTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.tostring.recursion; 2 | 3 | public class RecursionTest { 4 | 5 | public static void main(String[] args) { 6 | Manager manager = new Manager(); 7 | Developer developer = new Developer(); 8 | manager.setSubordinate(developer); 9 | developer.setManager(manager); 10 | System.out.println(developer.toString()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/importannotation/metaannotation/MainConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.importannotation.metaannotation; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | @EnableCounter 8 | public class MainConfiguration { 9 | 10 | @Bean 11 | public ImpressionService impressionService(Counter counter) { 12 | return new ImpressionService(counter); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-core/src/test/java/com/javabyexamples/spring/core/usingautowired/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingautowired; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @ContextConfiguration(classes = Application.class) 10 | public class ApplicationTest { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/eventlistener/TemperatureScreen.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.eventlistener; 2 | 3 | import org.springframework.context.ApplicationListener; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class TemperatureScreen implements ApplicationListener { 8 | 9 | @Override 10 | public void onApplicationEvent(TemperatureEvent event) { 11 | System.out.println("Temperature is " + event.getTemperature()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-core/src/test/java/com/javabyexamples/spring/core/annotationconfig/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.annotationconfig; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @ContextConfiguration(classes = Application.class) 10 | public class ApplicationTest { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-core/src/test/java/com/javabyexamples/spring/core/awareinterfaces/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.awareinterfaces; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @ContextConfiguration(classes = Application.class) 10 | public class ApplicationTest { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-core/src/test/java/com/javabyexamples/spring/core/beanpostprocessor/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.beanpostprocessor; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @ContextConfiguration(classes = Application.class) 10 | public class ApplicationTest { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-core/src/test/java/com/javabyexamples/spring/core/customqualifier/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.customqualifier; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @ContextConfiguration(classes = Application.class) 10 | public class ApplicationTest { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/restwithjson/view/Customer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.restwithjson.view; 2 | 3 | import com.fasterxml.jackson.annotation.JsonView; 4 | import lombok.Data; 5 | 6 | @Data 7 | @JsonView(PublicDetails.class) 8 | public class Customer { 9 | 10 | private String name; 11 | 12 | private String lastName; 13 | 14 | @JsonView(PrivateDetails.class) 15 | private String country; 16 | 17 | @JsonView(PrivateDetails.class) 18 | private String creditCardNumber; 19 | } 20 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/test/java/com/javabyexamples/java/mapper/orika/generics/collections/PersonGroupDto.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.generics.collections; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class PersonGroupDto { 7 | 8 | private List members = new ArrayList<>(); 9 | 10 | public List getMembers() { 11 | return members; 12 | } 13 | 14 | public void setMembers(List members) { 15 | this.members = members; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /java-and-test/junitrule/src/test/java/com/javabyexamples/java/test/junit/rule/custom/ignore/CustomIgnore.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.test.junit.rule.custom.ignore; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Inherited; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Target({ElementType.TYPE, ElementType.METHOD}) 11 | @Inherited 12 | public @interface CustomIgnore { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/builder/constructorlevel/Student.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.builder.constructorlevel; 2 | 3 | import lombok.Builder; 4 | 5 | public class Student { 6 | 7 | private String name; 8 | private int age; 9 | private String section; 10 | private String school; 11 | 12 | @Builder 13 | public Student(String section, String school) { 14 | this.section = section; 15 | this.school = school; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /maven-and-plugins/failsafe/src/test/java/com/javabyexamples/maven/plugins/failsafe/SampleIT.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.maven.plugins.failsafe; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class SampleIT { 7 | 8 | private Person person = new Person(); 9 | 10 | @Test 11 | public void shouldSayHello() { 12 | Assert.assertEquals("Hello", person.sayHello()); 13 | } 14 | 15 | @Test 16 | public void shouldSayBye() { 17 | Assert.assertEquals("Bye", person.sayBye()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/scopeddependency/defaultbehavior/AnotherClientService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.scopeddependency.defaultbehavior; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class AnotherClientService { 7 | 8 | private final Timer timer; 9 | 10 | public AnotherClientService(Timer timer) { 11 | this.timer = timer; 12 | } 13 | 14 | public void doWork() { 15 | timer.start(); 16 | timer.stop(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-core/src/test/java/com/javabyexamples/spring/core/disambiguatingbeans/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.disambiguatingbeans; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ContextConfiguration; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @ContextConfiguration(classes = Application.class) 10 | public class ApplicationTest { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/equalsandhashcode/recursion/RecursionClient.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.equalsandhashcode.recursion; 2 | 3 | public class RecursionClient { 4 | 5 | public static void main(String[] args) { 6 | Manager manager = new Manager(); 7 | Employee employee = new Employee(); 8 | manager.setSubordinate(employee); 9 | employee.setManager(manager); 10 | System.out.println(employee.hashCode()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/usingbean/incomponent/DefaultSampleService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.usingbean.incomponent; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | 5 | public class DefaultSampleService implements SampleService { 6 | 7 | @Override 8 | public void perform() { 9 | System.out.println("Performing..."); 10 | } 11 | 12 | @Bean 13 | public DefaultSampleRepository sampleRepository() { 14 | return new DefaultSampleRepository(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/jacksonconfiguration/properties/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.jacksonconfiguration.properties; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | new SpringApplicationBuilder().main(Application.class).profiles("jacksonconfigure").run(args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/mdc/interceptor/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.mdc.interceptor; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | new SpringApplicationBuilder().main(com.javabyexamples.spring.mvc1.mdc.filter.Application.class).profiles("mdc").run(args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/serverconfiguration/properties/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.serverconfiguration.properties; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | new SpringApplicationBuilder().main(Application.class).profiles("serverproperties").run(args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-mvc-2/src/main/java/com/javabyexamples/spring/mvc2/serverconfiguration/properties/Application.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc2.serverconfiguration.properties; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | new SpringApplicationBuilder().main(Application.class).profiles("serverproperties").run(args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /java-and-tools/lombok/src/main/java/com/javabyexamples/java/tools/lombok/annotations/constructors/requiredargs/Employee.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.tools.lombok.annotations.constructors.requiredargs; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | 5 | @RequiredArgsConstructor 6 | public class Employee { 7 | 8 | private final String name; 9 | private int salary; 10 | } 11 | 12 | @RequiredArgsConstructor(staticName = "of") 13 | class Department { 14 | 15 | private final String location; 16 | private final String employeeNumber; 17 | } 18 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/eventlistener/TemperatureEvent.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.eventlistener; 2 | 3 | import org.springframework.context.ApplicationEvent; 4 | 5 | public class TemperatureEvent extends ApplicationEvent { 6 | 7 | private final int temperature; 8 | 9 | public TemperatureEvent(Object source, int temperature) { 10 | super(source); 11 | this.temperature = temperature; 12 | } 13 | 14 | public int getTemperature() { 15 | return temperature; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/scopeddependency/beanlookup/Timer.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.scopeddependency.beanlookup; 2 | 3 | import java.util.UUID; 4 | 5 | public class Timer { 6 | 7 | private final String id = UUID.randomUUID().toString(); 8 | private long start; 9 | 10 | public void start() { 11 | start = System.nanoTime(); 12 | } 13 | 14 | public void stop() { 15 | long elapsed = System.nanoTime() - start; 16 | System.out.println(id + ": " + elapsed); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/customqualifier/Version1.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.customqualifier; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | import org.springframework.beans.factory.annotation.Qualifier; 8 | 9 | @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE}) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Qualifier 12 | public @interface Version1 { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-core/src/main/java/com/javabyexamples/spring/core/customqualifier/Version2.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.customqualifier; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | import org.springframework.beans.factory.annotation.Qualifier; 8 | 9 | @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE}) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Qualifier 12 | public @interface Version2 { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /java-and-mapper/orika/src/main/java/com/javabyexamples/java/mapper/orika/immutable/Car.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.mapper.orika.immutable; 2 | 3 | public class Car { 4 | 5 | private final String brand; 6 | private final String horsePower; 7 | 8 | public Car(String brand, String horsePower) { 9 | this.brand = brand; 10 | this.horsePower = horsePower; 11 | } 12 | 13 | public String getBrand() { 14 | return brand; 15 | } 16 | 17 | public String getHorsePower() { 18 | return horsePower; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /java-and-test/mockito/README.md: -------------------------------------------------------------------------------- 1 | # Mockito 2 | 3 | Some examples are detailed in the following blog posts: 4 | - http://www.javabyexamples.com/mockito-recipe-capture-arguments-with-argumentcaptor/ 5 | - http://www.javabyexamples.com/mockito-recipe-return-given-arguments/ 6 | - http://www.javabyexamples.com/mockito-recipe-custom-return-with-answer/ 7 | - http://www.javabyexamples.com/mockito-recipe-expectation-override/ 8 | - http://www.javabyexamples.com/mockito-recipe-multiple-expectations-on-a-mock/ 9 | - http://www.javabyexamples.com/mockito-recipe-mock-initialization/ 10 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/closecontext/MonitorService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.closecontext; 2 | 3 | import javax.annotation.PostConstruct; 4 | import javax.annotation.PreDestroy; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class MonitorService { 9 | 10 | @PostConstruct 11 | public void init() { 12 | System.out.println("Initialized..."); 13 | } 14 | 15 | @PreDestroy 16 | public void destroy() { 17 | System.out.println("Destroying..."); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-core-3/src/main/java/com/javabyexamples/spring/core/spel/beanusage/RandomService.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.spel.beanusage; 2 | 3 | import org.apache.commons.lang3.RandomStringUtils; 4 | import org.apache.commons.lang3.RandomUtils; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class RandomService { 9 | 10 | public String randomName() { 11 | return RandomStringUtils.randomAlphabetic(5); 12 | } 13 | 14 | public int randomNumber() { 15 | return RandomUtils.nextInt(0, 100); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-mvc-1/src/main/java/com/javabyexamples/spring/mvc1/interceptor/ApiController.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.mvc1.interceptor; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | @RequestMapping("api") 9 | public class ApiController { 10 | 11 | @GetMapping("/stats") 12 | public String stats() { 13 | System.out.println("stats()"); 14 | return "stats"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /java-and-concurrency/advanced/src/main/java/com/javabyexamples/java/concurrency/composing/instanceconfinement/MutablePoint.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.java.concurrency.composing.instanceconfinement; 2 | 3 | import com.javabyexamples.java.concurrency.common.annotation.Mutable; 4 | 5 | @Mutable 6 | public class MutablePoint { 7 | 8 | public int x, y; 9 | 10 | public MutablePoint() { 11 | x = 0; 12 | y = 0; 13 | } 14 | 15 | public MutablePoint(MutablePoint p) { 16 | this.x = p.x; 17 | this.y = p.y; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-core-2/src/main/java/com/javabyexamples/spring/core/componentindex/custom/CustomIndexed.java: -------------------------------------------------------------------------------- 1 | package com.javabyexamples.spring.core.componentindex.custom; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | import org.springframework.stereotype.Indexed; 9 | 10 | @Target(ElementType.TYPE) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Documented 13 | @Indexed 14 | public @interface CustomIndexed { 15 | 16 | } 17 | --------------------------------------------------------------------------------