Giter Site home page Giter Site logo

dylancodeverse / generic Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 4.82 MB

"Generic Java Libraries" is a repository focused on providing reusable and generalized Java libraries to simplify common programming tasks. The goal of this project is to offer developers pre-built functionalities that can be easily integrated into their Java projects.

Java 99.92% Shell 0.08%
generic-programming generic-sort

generic's Introduction

Getting Started

Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.

Folder Structure

The workspace contains two folders by default, where:

  • src: the folder to maintain sources
  • lib: the folder to maintain dependencies

Meanwhile, the compiled output files will be generated in the bin folder by default.

If you want to customize the folder structure, open .vscode/settings.json and update the related settings there.

Dependency Management

The JAVA PROJECTS view allows you to manage your dependencies. More details can be found here.

Key Features

  • Form Generation Library: A generic library that allows developers to create forms for any object in their Java applications. This library streamlines the process of generating user interfaces and data entry forms.

  • Sorting Library: A versatile sorting library that can be applied to any object type. It provides various sorting algorithms to efficiently organize data collections.

Generate FORM

Your object should extends generic.Generic

Here's an example :

import java.util.Date;

import generic.Generic;

public class Person extends Generic<Person>{

String name ;
int age ;
Date dateDeNaissance;
boolean isDispo =false ;
Physic physic ;


public Person(String name,Physic physic) {
    this.name = name;
    this.physic = physic;
}

public Person(String name, int age) {
    this.name = name;
    this.age = age;
}


public Person(String name, int age, Date dateDeNaissance) {
 
    this.name = name;
    this.age = age;
    this.dateDeNaissance = dateDeNaissance;

}

public Person(){

    super();

}

There's two options for you:

  • getFormHTML (String action , String method , String... ignore): Each label for the form is the field's default name

  • getFormHTMLSpecified (String action ,String method ,String [] fieldsName , String ... ignore): You can specify each label for the form

case 1:

new Person().getFormHTML( "Treatment.jsp", "GET")

case 2:

new Person().getFormHTML( "Treatment.jsp", "GET", new String []{"dateDeNaissance","age"})

case 3

new Person().getFormHTML( "Treatment.jsp", "GET", "dateDeNaissance","age")

case 4

new Person().getFormHTMLSpecified("traitement", "get" , 
     new String[] { "Nom","Age" , "Est disponible" } ,"dateDeNaissance" )

case 5

new Person().getFormHTMLSpecified("traitement", "get" , 
     new String[] { "Nom","Age" ,"Date de naissance" , "Est disponible" }  )

Generic sort

Always extends Generic

case 1 : Similar to ORDER BY age, name of SQL

Person[] ps = new Person[]{
    new Person("Cocou", 19),
    new Person("Sab", 456),
    new Person("ali", 0),
    new Person("bbe", 0),
    new Person("John", 25),
    new Person("Alice", 30),
    new Person("Bob", 21)
};

Person.sort(ps, new String []{"age","name"});

case 2 : sort Person by Person.Physic.weight

Person[] pss = new Person[]{
    new Person("Alice", new Physic(12)),
    new Person("Bob", new Physic(10)),
    new Person("Charlie", new Physic(15))
};


HashMap <String ,DeepField > map = new HashMap<String ,DeepField>();
map.put("physic", new DeepField(new String[]{"physic","weight"}));
    
Person.sort(pss, new String[]{"physic"},map);

case 3 : sort by Person.Physic.weight and Name

HashMap <String ,DeepField > map = new HashMap<String ,DeepField>();
        map.put("physic", new DeepField(new String[]{"physic","weight"}));

Person.sort(pss, new String[]{"physic","name"},map);

SUM and AVERAGE

Always extends Generic

import generic.util.Generic;

public class Prix extends Generic<Prix> {
    String id;
    Double prixCoca;
    Double prixChoco;

    public Prix()
    {
    }
    public Prix(Double prixCoca, Double prixChoco) 
    {
        super();

        this.prixCoca = prixCoca;
        this.prixChoco = prixChoco;
    }
}

Initialisation:

Prix[] prixList = new Prix[] {
    new Prix(10., 15.),
    new Prix(5., 8.),
    new Prix(12., 20.)
};

Test sum:

Prix result = new Prix().sum(prixList, new String[]{"prixCoca","prixChoco"});

sum prixCoca = result.prixcoca , sum prixChoco = result.prixChoco

Test average:

Prix p1= new Prix().average(prixList, new String[]{"prixCoca","prixChoco"});

generic's People

Contributors

dylancodeverse avatar misafenosoa avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.