Skip to content

Commit

Permalink
provide an initial module and stubs (iluwatar#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergejsvisockis committed Apr 15, 2024
1 parent f52f71c commit fedbb99
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 0 deletions.
30 changes: 30 additions & 0 deletions active-record/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--- # this is so-called 'YAML front matter' used to categorize the patterns and format the web pages. Fill it as follows:
title: Best Pattern Ever # the properly formatted title
category: Creational # usable categories and tags are listed here: https://github.com/iluwatar/java-design-patterns/wiki/07.-Categories-and-Tags
language: en # Provide the language in which the pattern is done. Mostly it is in English, so we would put *en* over here.
tag:
- awesome # usable categories and tags are listed here: https://github.com/iluwatar/java-design-patterns/wiki/07.-Categories-and-Tags
- blue
---

## Name / classification

## Also known as

## Intent

## Explanation

## Class diagram

## Applicability

## Tutorials

## Known uses

## Consequences

## Related patterns

## Credits
3 changes: 3 additions & 0 deletions active-record/etc/active-record.urm.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@startuml

@enduml
56 changes: 56 additions & 0 deletions active-record/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.26.0-SNAPSHOT</version>
</parent>

<artifactId>active-record</artifactId>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.dao.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.iluwatar.activerecord;

import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@RequiredArgsConstructor
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class Customer {

private Long id;
private String customerNumber;
private String firstName;
private String lastName;
private List<Order> orders;

public Customer findById(Long id) {
return new Customer();
}

public Customer findByNumber(String customerNumber) {
return new Customer();
}

public List<Customer> findAll() {
return List.of();
}

public void save(Customer customer) {

}

}
18 changes: 18 additions & 0 deletions active-record/src/main/java/com/iluwatar/activerecord/Order.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.iluwatar.activerecord;

import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@NoArgsConstructor
@AllArgsConstructor
public class Order {

private Long id;
private String orderNumber;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.iluwatar.activerecord;

import javax.sql.DataSource;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
public abstract class RecordBase {

private final DataSource dataSource;

}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
<module>gateway</module>
<module>slob</module>
<module>server-session</module>
<module>active-record</module>
</modules>
<repositories>
<repository>
Expand Down

0 comments on commit fedbb99

Please sign in to comment.