Commit ed790908 authored by Gerson Sunyé's avatar Gerson Sunyé

Move code to new repository

parent f243ad9b
Pipeline #15925 passed with stages
in 39 seconds
<component name="libraryTable">
<library name="Gradle: org.apiguardian:apiguardian-api:1.0.0">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.apiguardian/apiguardian-api/1.0.0/3ef5276905e36f4d8055fe3cb0bdcc7503ffc85d/apiguardian-api-1.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.apiguardian/apiguardian-api/1.0.0/777508fa9f3e03cafb3c1fb2eba3dca317f4b1ee/apiguardian-api-1.0.0-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Gradle: org.junit.jupiter:junit-jupiter-api:5.0.3">
<CLASSES>
<root url="file://$PROJECT_DIR$/Could not resolve org.junit.jupiter:junit-jupiter-api:5.0.3." />
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter-api/5.0.3/43872be66bab0172073ac698062419755e563353/junit-jupiter-api-5.0.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter-api/5.0.3/61fbfdfc77ddcd708fe1a740d292fed04aec5527/junit-jupiter-api-5.0.3-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Gradle: org.junit.jupiter:junit-jupiter-engine:5.0.3">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter-engine/5.0.3/52fcc461185c48178608f687e962de6484dfb69e/junit-jupiter-engine-5.0.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter-engine/5.0.3/e6352b8b5e96031caa21f0d6f799d559a13960f5/junit-jupiter-engine-5.0.3-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Gradle: org.junit.jupiter:junit-jupiter-params:5.0.3">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter-params/5.0.3/2040154af126813745d61af0496f579ff688d20e/junit-jupiter-params-5.0.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter-params/5.0.3/a9b1202ae91d4fbe80c589a99efab8c3a0ef84b6/junit-jupiter-params-5.0.3-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Gradle: org.junit.platform:junit-platform-commons:1.0.3">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.junit.platform/junit-platform-commons/1.0.3/3663f3ddfe47df2a7bf363d5c0196f0c7a09820f/junit-platform-commons-1.0.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.junit.platform/junit-platform-commons/1.0.3/112d0f72ac2aa049c9004e1f76d05ec49a83e283/junit-platform-commons-1.0.3-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Gradle: org.junit.platform:junit-platform-engine:1.0.3">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.junit.platform/junit-platform-engine/1.0.3/7028a17adabd876b6d7530e43523a7f4fd109e18/junit-platform-engine-1.0.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.junit.platform/junit-platform-engine/1.0.3/b250bf811bb2bd2160bc6a6d9804453c389f502a/junit-platform-engine-1.0.3-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Gradle: org.opentest4j:opentest4j:1.0.0">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.opentest4j/opentest4j/1.0.0/6f09c598e9ff64bf0ce2fa7e7de49a99ba83c0b4/opentest4j-1.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.opentest4j/opentest4j/1.0.0/a67ba0f50d97fa616f2470c5a48eb7f9eb38391c/opentest4j-1.0.0-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_LPz7kBCCEei8I66bYraWpA" name="NewModel"/>
group 'fr.unantes'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = 1.8
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.0.3'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.0.3'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.0.3'
}
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<viewpoint:DAnalysis xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:viewpoint="http://www.eclipse.org/sirius/1.1.0" xsi:schemaLocation="http://www.eclipse.org/sirius/description/1.1.0 http://www.eclipse.org/sirius/1.1.0#//description" xmi:id="_LNY5sBCCEei8I66bYraWpA" selectedViews="_LSCwMBCCEei8I66bYraWpA _LSIPwBCCEei8I66bYraWpA _LSKE8BCCEei8I66bYraWpA _LSMhMBCCEei8I66bYraWpA _LSOWYBCCEei8I66bYraWpA" version="11.1.0.201608251200">
<semanticResources>.idea/compiler.xml</semanticResources>
<semanticResources>.idea/gradle.xml</semanticResources>
<semanticResources>.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml</semanticResources>
<semanticResources>.idea/libraries/Gradle__org_apache_commons_commons_lang3_3_7.xml</semanticResources>
<semanticResources>.idea/libraries/Gradle__org_apiguardian_apiguardian_api_1_0_0.xml</semanticResources>
<semanticResources>.idea/libraries/Gradle__org_junit_jupiter_junit_jupiter_api_5_0_3.xml</semanticResources>
<semanticResources>.idea/libraries/Gradle__org_junit_jupiter_junit_jupiter_engine_5_0_3.xml</semanticResources>
<semanticResources>.idea/libraries/Gradle__org_junit_jupiter_junit_jupiter_params_5_0_3.xml</semanticResources>
<semanticResources>.idea/libraries/Gradle__org_junit_platform_junit_platform_commons_1_0_3.xml</semanticResources>
<semanticResources>.idea/libraries/Gradle__org_junit_platform_junit_platform_engine_1_0_3.xml</semanticResources>
<semanticResources>.idea/libraries/Gradle__org_opentest4j_opentest4j_1_0_0.xml</semanticResources>
<semanticResources>.idea/misc.xml</semanticResources>
<semanticResources>.idea/modules.xml</semanticResources>
<semanticResources>.idea/vcs.xml</semanticResources>
<semanticResources>.idea/workspace.xml</semanticResources>
<semanticResources>agenda.uml</semanticResources>
<ownedViews xmi:type="viewpoint:DView" xmi:id="_LSCwMBCCEei8I66bYraWpA">
<viewpoint xmi:type="description:Viewpoint" href="platform:/plugin/org.obeonetwork.dsl.uml2.design/description/uml2.odesign#//@ownedViewpoints[name='Reused']"/>
</ownedViews>
<ownedViews xmi:type="viewpoint:DView" xmi:id="_LSIPwBCCEei8I66bYraWpA">
<viewpoint xmi:type="description:Viewpoint" href="platform:/plugin/org.obeonetwork.dsl.uml2.design/description/uml2.odesign#//@ownedViewpoints[name='Capture']"/>
</ownedViews>
<ownedViews xmi:type="viewpoint:DView" xmi:id="_LSKE8BCCEei8I66bYraWpA">
<viewpoint xmi:type="description:Viewpoint" href="platform:/plugin/org.obeonetwork.dsl.uml2.design/description/uml2.odesign#//@ownedViewpoints[name='Design']"/>
</ownedViews>
<ownedViews xmi:type="viewpoint:DView" xmi:id="_LSMhMBCCEei8I66bYraWpA">
<viewpoint xmi:type="description:Viewpoint" href="platform:/plugin/org.obeonetwork.dsl.uml2.design/description/uml2.odesign#//@ownedViewpoints[name='Review']"/>
</ownedViews>
<ownedViews xmi:type="viewpoint:DView" xmi:id="_LSOWYBCCEei8I66bYraWpA">
<viewpoint xmi:type="description:Viewpoint" href="platform:/plugin/org.obeonetwork.dsl.uml2.design/description/uml2.odesign#//@ownedViewpoints[name='Extend']"/>
</ownedViews>
</viewpoint:DAnalysis>
package fr.unantes.alarms;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
/**
* Created on 19/01/2018.
*
* @author NaoMod team.
*/
public class Alarm {
private final BlockingQueue<Notify> notifications = new ArrayBlockingQueue<Notify>(10);
public void accept(Notify notify) {
this.notifications.offer(notify);
}
// TODO: write a thread that reads the blocking queue and executes the notification.
}
package fr.unantes.alarms;
import java.io.Serializable;
import java.util.Objects;
/**
* Created on 19/01/2018.
*
* @author NaoMod team.
*/
public class Notify implements Serializable {
public final String message;
public Notify(String message) {
this.message = message;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Notify notify = (Notify) o;
return Objects.equals(message, notify.message);
}
@Override
public int hashCode() {
return Objects.hash(message);
}
}
package fr.unantes.bidirectional;
/**
* Created on 18/01/2018.
*
* @author NaoMod team.
*/
public class File {
private Folder folder;
public File(Folder aFolder) {
folder = aFolder;
}
public Folder getFolder() {
return folder;
}
}
package fr.unantes.bidirectional;
import fr.unantes.unidirectional.collections.HTMLPage;
import java.util.Collection;
import java.util.Iterator;
/**
* Created on 18/01/2018.
*
* @author NaoMod team.
*/
public class FileCollection implements Collection<File> {
private Collection<File> pages;
public FileCollection(Collection<File> list) {
this.pages = list;
}
public int size() {
return pages.size();
}
public boolean isEmpty() {
return pages.isEmpty();
}
public boolean contains(Object o) {
return pages.contains(o);
}
public Iterator<File> iterator() {
// TODO: Implement the Iterator!
return pages.iterator();
}
public Object[] toArray() {
return pages.toArray();
}
public <T> T[] toArray(T[] a) {
return pages.toArray(a);
}
public boolean add(File file) {
return pages.add(file);
}
public boolean remove(Object o) {
return false;
}
public boolean containsAll(Collection<?> c) {
return pages.containsAll(c);
}
public boolean addAll(Collection<? extends File> c) {
return pages.addAll(c);
}
public boolean addAll(int index, Collection<? extends File> c) {
return false;
}
public boolean removeAll(Collection<?> c) {
return pages.removeAll(c);
}
public boolean retainAll(Collection<?> c) {
return pages.retainAll(c);
}
public void clear() {
pages.clear();
}
public File get(int index) {
return get(index);
}
public File set(int index, HTMLPage element) {
return set(index, element);
}
public boolean remove(int index) {
return pages.remove(index);
}
public int lastIndexOf(Object o) {
return lastIndexOf(o);
}
}
package fr.unantes.bidirectional;
import java.util.ArrayList;
/**
* Created on 18/01/2018.
*
* @author NaoMod team.
*/
public class Folder {
private FileCollection files = new FileCollection(new ArrayList<File>());
public FileCollection getFiles() {
return files;
}
}
package fr.unantes.library;
/**
* Created on 23/01/2018.
*
* @author NaoMod team.
*/
class Available extends DefaultBookState {
@Override
public void borrow() {
// TODO
}
}
package fr.unantes.library;
/**
* Created on 23/01/2018.
*
* @author NaoMod team.
*/
public interface Book {
boolean reserve(Reader aReader);
void deliver();
void borrow();
void returnBook();
boolean isAvailable();
Integer id();
String title();
}
package fr.unantes.library;
/**
* Created on 23/01/2018.
*
* @author NaoMod team.
*/
public interface BookState {
boolean reserve(Reader aReader);
void deliver();
void borrow();
void returnBook();
}
package fr.unantes.library;
/**
* Created on 23/01/2018.
*
* @author NaoMod team.
*/
public class BookWithStates implements Book {
private BookState state = new Ordered();
@Override
public boolean reserve(Reader aReader) {
return state.reserve(aReader);
}
@Override
public void deliver() {
state.deliver();
}
@Override
public void borrow() {
state.borrow();
}
@Override
public void returnBook() {
state.returnBook();
}
@Override
public boolean isAvailable() {
return false;
}
@Override
public Integer id() {
return null;
}
@Override
public String title() {
return null;
}
}
package fr.unantes.library;
/**
* Created on 23/01/2018.
*
* @author NaoMod team.
*/
class Borrowed extends DefaultBookState {
@Override
public void returnBook() {
// TODO
}
}
package fr.unantes.library;
/**
* Created on 25/01/2018.
*
* @author sunye.
*/
public class Borrowing {
private Book book;
private Member member;
public Borrowing(Member member, Book book) {
this.book = book;
this.member = member;
}
public Book book() {
return book;
}
public Member member() {
return member;
}
}
package fr.unantes.library;
/**
* Created on 23/01/2018.
*
* @author NaoMod team.
*/
public class DefaultBookState implements BookState {
@Override
public boolean reserve(Reader aReader) {
throw new IllegalStateException();
}
@Override
public void deliver() {
throw new IllegalStateException();
}
@Override
public void borrow() {
throw new IllegalStateException();
}
@Override
public void returnBook() {
throw new IllegalStateException();
}
}
package fr.unantes.library;
import org.apache.commons.lang3.Validate;
import java.util.*;
/**
* Created on 25/01/2018.
*
* @author sunye.
*/
public class Library {
private Map<Integer, Book> books = new HashMap<>();
private Map<Integer, Member> members = new HashMap<>();
private List<Borrowing> borrowings = new ArrayList<>();
public boolean borrow(Integer memberId, Integer bookId) {
Member member;
if (!books.containsKey(bookId)) {return false;}
Book book = books.get(bookId);
if (!book.isAvailable()) { return false;}
if (!members.containsKey(memberId)) {
member = this.registerMember(memberId);
} else {
member = members.get(memberId);
if (member.isMaxQuotaExceed()) {
return false;
}
}
Borrowing borrowing = new Borrowing(member, book);
this.borrowings.add(borrowing);
return true;
}
public Member registerMember(Integer newMemberId) {
return new Member();
}
public void returnBook(Integer bookId) {
Validate.isTrue(bookId > 0);
Borrowing borrowing = borrowings.stream()
.filter(each -> each.book().id() == bookId)
.findFirst()
.get();
borrowing.book().returnBook();
borrowing.member().borrowed().remove(borrowing.book());
}
public void reserve(String title, Integer memberId, Calendar date) {
}
public void createMember(Integer id, String name) {}
public void createBook(Integer id, String title) {}
public List<Reservation> reservations () {
return new ArrayList<>();
}
}
package fr.unantes.library;
import java.util.ArrayList;
import java.util.List;
/**
* Created on 25/01/2018.
*
* @author sunye.
*/
public class Member {
public boolean isMaxQuotaExceed() {
return false;
}
public List<Book> borrowed() {
return new ArrayList<>();
}
public Integer id() {
return Integer.valueOf(11);
}
}