Code Monkey home page Code Monkey logo

sweetener's People

Contributors

lstypka avatar tkurylek avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

sweetener's Issues

SW-4 Truncate method in the Collections

Implementation of the truncate method:

public static List<?> truncate(List<?> list, int from, int to)

This method should return sub-list of list passed as first parameter. The possible value of to is -1 which indicates list.size()-1.

SW-29 Support mapping collections of mappable objects

AnnotationDrivenMapper cannot map collections of mappable objects.

Suppose we have a class StudentWithListOfGrades that looks like follows:

class StudentWithListOfGrades {
   List<Grade> grades;
}

and a class StudentWithListOfGradeSnapshots:

class StudentWithListOfGradeSnapshots {
   List<GradeSnapshot> gradeSnapshots;
}

Assuming Grade is mappable to GradeSnapshot, properly annotated and working with AnnotationDrivenMapper I would like to map StudentWithListOfGrades to StudentWithListOfGradeSnapshots. Currently it's not possible.

SW-25 Maths - new methods

// For all number types!

  • sequence(start, stop, step)
  • sequence(start, stop, interface satisfies { boolean satisfies(...) {} });
  • adjustToRange(value, min, max, Range.LEFT_CLOSED, RIGHT_CLOSED, BOTH_CLOSED)
  • byte : add with saturation ( byte, byte) // 120 + 5 = 125; 125+5 = 127; 127+1 = 127 etc
  • byte: wrapTo(byte, byte, byte startingNumber) // startingNumber: 100 => 120+5 = 125; 125+5 = 102, 102 + 30 = 105
  • random for BigInteger
  • random for BigDecimal
  • isZero(BigInteger)
  • isZero(BigDecimal)
  • isPositive(BigInteger)
  • isPositive(BigDecimal)
  • isNegative(BigInteger)
  • isNegative(BigDecimal)
  • mathematics methods for BigInteger BigDecimal (sqrt, etc ... )

SW-3 Configure Jenkins CI

Currently we have no feedback whether our project still builds after merge. Please configure Jenkins CI (for branch master).

Things you should concentrate on:

  • email notification for the team,
  • access to Jenkins should be public (read only),
  • build status with link to the CI in README file (consider using this plugin).

You can also add other plugins like Chuck Norris Plugin and Green Balls.

SW-7 Create Arrays

Create Arrays class with following methods:

  • extends (int)
  • extends (T ... args)

SW-30 Support mapping java.util.Map of mappable objects

AnnotationDrivenMapper cannot map java.util.Map of mappable objects.

Suppose we have a class StudentWithGrades that looks like follows:

class StudentWithGrades {
   Map<Exam, Grade> grades;
}

and a class StudentWithGradeSnapshots:

class StudentWithGradeSnapshots {
   Map<ExamSnapshot, GradeSnapshot> gradeSnapshots;
}

Assuming Grade is mappable to GradeSnapshot and Exam to ExamSnapshot, fields are properly annotated and working with AnnotationDrivenMapper, I would like to map StudentWithGrades to StudentWithGradeSnapshots. Currently it's not possible.

SW-20 Maths

Proposed methods:

Random

  • int randomInt(int lowerRange, int upperRange)
  • long randomLong(long lowerRange, long upperRange)
  • float randomFloat(float lowerRange, float upperRange)
  • double randomDouble(double lowerRange, double upperRange)

Distance

  • double distance(sourceX, sourceY, destinationX, destinationY);
  • double distance(sourceX, sourceY, sourceZ, destinationX, destinationY, destinationZ);
  • double distance(Point source, Point destination); (Point is interface, Point2D and Point3D are concrete classes)
  • SafeParse (for all types, ParseContext) // exception is not thrown when parsed string is not a number
    ParseContext: ALWAYS_ZERO, ZERO_WHEN_INCORRECT, MIN_AND_MAX_WHEN_OUT_OF_RANGE, EXCEPTION

Normalization

  • double normalize(value, lowerRange, upperRange);
  • Collection normalize(Collection) // Normalize the collection of number to collection of number from range < lowerRange; upperRange >. The same for all number types
  • minValue
  • maxValue
  • int adjustToRange(int lowerRange, int upperRange, int value)
  • long adjustToRange(long lowerRange, long upperRange, long value)
    etc...

Statistics

  • double average(Collection values)
  • double standardDeviation(Collection values)
  • double variance(Collection values)

SW-22 New methods for collections

  • duplicates(Collection<?>, String property) - search duplicates by given property, not by reference
  • unique(Collection<?>, String property) - the same as above, but there is returned list of unique elements
  • List<List> group(Collection, String fieldName) - returns list of groups, created by given value of field
  • List<List> group(Collection, String ... fieldNames) - returns list of groups, created by given value of fields

SW-13 Implement additional methods for Reflections.class

Implement the following methods for class Reflections.class:

  • Get elements annotated by given annotation
 // returns fields (including private) annotated by given annotation
public static List<Field> getFieldsAnnotatedBy(Object object, Class<? extends Annotation> annotation); 

// returns methods (including private) annotated by given annotation
public static List<Method> getMethodsAnnotatedBy(Object object, Class<? extends Annotation> annotation);  
// (...)
  • Get elements satisfying given condition
// return fields satisfying condition
public static List<Field> getFieldsSatisfyingCondition(Object object, Condition<Field> fieldCondition)
// return methods satisfying condition
public static List<Method> getMethodsSatisfyingCondtion(Object object, Condition<Method> methodsCondition);
// (...)
  • Implement condition interface:
public interface Condition<T> {
    boolean isSatisfied(T object);
}

SW-21 Arrays

Split string of numbers to array

  • byte[] splitByte(String value, String separator);
  • short[] splitShort(String value, String separator);
  • int[] splitInt(String value, String separator);
  • long[] splitLong(String value, String separator);
  • float[] splitFloat(String value, String separator);
  • double[] splitDouble(String value, String separator);

Resizing

  • T resize(T array, size)
  • extends (T array, int)
  • extends (T array, V ... args)
  • Filter (criteria)
  • Pagination
  • Chop

CollectionCriteria - dodanie 'OR'

W tej chwili mamy możliwość tworzenia zapytania tylko w postaci
where A=1 AND B=2 AND C=3
Należy dodać możliwość konstrukcji:
where (A=2 OR A=3) AND (C=3 OR D=5)

SW-24 New methods for Strings

  • boolean isNumeric(String)
  • boolean isAlpha(String)
  • boolean isAlphaNumeric(String)
  • boolean containsOnly(String, List c);
  • String pad(String value, int size, String content, PaddingType paddingType) (PaddingType : LEFT, RIGHT, CENTRE)
  • boolean isEmpty(String)
  • String removeWhiteSpaces(String)
  • String singleLine(String) - removes all \n \r
  • String removeNewLine(String) - removes \r \n from end of parameter
  • String reverse(String) - abc -> cba
  • String repeat(String, int) - (ab, 2) -> abab

SW-18 Resources

Well-known problem is finding resources from code.
Proposed methods:

  • applicationResource
  • localResource
  • remoteResource

This class should also allow you to save data in various forms:

  • stream
  • file
  • String

SW-19 Strings

Proposed methods:

  • String join(String sequence, Collection collection)
  • String join(String sequence, Object ... o)
  • int numberOfCccurrences(String sourceObject, String sequence);
  • int numberOfCccurrences(String sourceObject, Char c);
  • String removeAllOccurences(String sourceObject, String sequence);
  • String removeAllOccurences(String sourceObject, Char c);
  • int[] indexesOf(String sourceObject, String sequence);
  • int[] indexesOf(String sourceObject, Char c);
  • List< FoundGroup > groups(String sourceObject, String sequence);
  • String random(int length);
  • String random(List symbols, int length);
  • String pad(String value, int size) // default by spaces
  • String pad(String value, int size, String content)
  • String defaultIfNull(String value, String default)
  • String capitalize(String str) // Capitalize first letter
  • String capitalizeAllWords(String str) // Capitalize first letter of all words

@tkurylek Any suggestions are welcome!

Restriction - new functions

[x] notBetween
[x] in
[x] notIn
[x] before (Date, LocalDate, DateTime, LocalDateTime ... )
[x] after (Date, LocalDate, DateTime, LocalDateTime ... )

CollectionCriteria - Obsługa Map

Mapy także powinny być obsługiwane przez CollectionCriteria
Powinna byc możliwość tworzenia criteri na kluczu oraz wartosciach

SW-11 Think through new types of collections

I've got idea to create new types of collection, for example:

Graph (you know what I mean 😋 )
Tuple (something like part of table, known from SQL)

Feel free to editing of the description and adding the new types of collection.

SW-2 Create equals method for Objects class

Objects class should contain the following methods:

equals(Object, Object) - compare two objects (possible null value)
equals(Object, Object, String) - compare specific property of objects passed as third argument. (possible hierarchical path. eg: company.address.city)
equals(Object, String, Object, String) - compare specific property of objects passed as second (for first object) and fourth (for second object) argument. (possible hierarchical path. eg: company.address.city)

SW-26 Histogram

Implement two type of histogram:
DiscreteHistogram();
RangeHistogram(double[] ranges);

SW-28 Allow specifying multiple classes in @Map(of=...) parameter

Suppose we have class Foo that is mappable to classes: A, B, C. We want to map bar field only to A and B classes. The following code works but we need to specify two different mappings - one for A class and one for B.

@MappableTo(A.class, B.class, C.class)
class Foo {
   @Mappings({
      @Map(to = "bar", of = A.class),
      @Map(to = "bar", of = B.class)
   })
   Bar bar;
}

I would like to specify multiple classes in @Map(of=...) parameter so the code looks like this:

@MappableTo(A.class, B.class, C.class)
class Foo {
   @Map(to = "bar", of = {A.class, B.class})
   Bar bar;
}

SW-16 New feature for AnnotationDrivenMapper

What do you think about following case:
As user I would like to map one class to many other classes.

In my opinion, the annotation @MapExactlyTo may contains annother optional value : class.

or instead of class as parameter we might receive symbolic name:

@MappableTo(class = StudentSnapshot.class, symbolicName = "studentSnapshot")
@MapExactlyTo(field = "semester", symbolicName = "studentSnapshot")
private int semester;

SW-27 Stopwatch and Watch

These classes should allow user to getting time in many variants of time (h, min, s, ms, us etc).
These classes shouldn't have static methods!

SW-12 Create Pagination mechanism for Collection

Consider Pagination for collection passed as parameter.
The pagination method should return Pagination object:

public static Pagination paginate(Collection, int page, int resultsPerPage);

class Pagination {
  int page;
  int resultPerPage;
  int numberOfPage;
  Collection<T> elementsOfPage;
}

or maybe the better idea is:

class Pagination {
  int page;
  int resultPerPage;
  int numberOfPage;
  List<Collection<T> > listOfPages;

  Collection<T> getElementsOfPage();
  nextPage();
  previousPage();

  etc...
}

@tkurylek What do you think about it? In your opinion which option is better?

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.