All Projects → forax → Exotic

forax / Exotic

Licence: mit
A bestiary of classes implementing exotic semantics in Java

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Exotic

Statusbarutil
Android沉浸式状态栏,支持状态栏渐变色,纯色, 全屏,亮光、暗色模式,适配android 4.4 -10.0机型,支持刘海屏,滴水屏
Stars: ✭ 373 (+292.63%)
Mutual labels:  utility-library
Medley
A lightweight library of useful Clojure functions
Stars: ✭ 622 (+554.74%)
Mutual labels:  utility-library
Sassyfication
💅Library with sass mixins to speed up your css workflow.
Stars: ✭ 51 (-46.32%)
Mutual labels:  utility-library
Lodash Php
Easy to use utility functions for everyday PHP projects. This is a port of the Lodash JS library to PHP
Stars: ✭ 412 (+333.68%)
Mutual labels:  utility-library
Ubelt
A Python utility belt containing simple tools, a stdlib like feel, and extra batteries. Hashing, Caching, Timing, Progress, and more made easy!
Stars: ✭ 561 (+490.53%)
Mutual labels:  utility-library
Utils
A collection of useful PHP functions, mini classes and snippets that you need and can use every day.
Stars: ✭ 750 (+689.47%)
Mutual labels:  utility-library
Vueuse
Collection of essential Vue Composition Utilities for Vue 2 and 3
Stars: ✭ 7,290 (+7573.68%)
Mutual labels:  utility-library
Tanya
GC-free, high-performance D library: Containers, networking, metaprogramming, memory management, utilities
Stars: ✭ 70 (-26.32%)
Mutual labels:  utility-library
Vue Use Web
🕸 Web APIs implemented as Vue.js composition functions
Stars: ✭ 603 (+534.74%)
Mutual labels:  utility-library
C Utils
Tiny, modular, drop-in, library of some most commonly used utility methods for C (embedded) applications. Intended to be used as a git-submodule inside your projects to kickstart development. See https://c-utils.gotomain.io for more details.
Stars: ✭ 47 (-50.53%)
Mutual labels:  utility-library
Prettytable
Display tabular data in a visually appealing ASCII table format
Stars: ✭ 410 (+331.58%)
Mutual labels:  utility-library
Sugar
A Javascript library for working with native objects.
Stars: ✭ 4,457 (+4591.58%)
Mutual labels:  utility-library
Awaity.js
A functional, lightweight alternative to bluebird.js, built with async / await in mind.
Stars: ✭ 818 (+761.05%)
Mutual labels:  utility-library
Craig S Utility Library
A giant set of utility classes originally start back in the .Net 2.0 days and updated until .Net Core and .Net Standard became a thing. At which point I took the library and broke it up into a ton of smaller libraries. View my profile for more up to date versions of everything.
Stars: ✭ 397 (+317.89%)
Mutual labels:  utility-library
Puredata Abstractions
Some abstractions for Puredata: Simple loopers, effects and helpers.
Stars: ✭ 63 (-33.68%)
Mutual labels:  utility-library
Jodd
Jodd! Lightweight. Java. Zero dependencies. Use what you like.
Stars: ✭ 3,616 (+3706.32%)
Mutual labels:  utility-library
Vue Composable
Vue composition-api composable components. i18n, validation, pagination, fetch, etc. +50 different composables
Stars: ✭ 638 (+571.58%)
Mutual labels:  utility-library
Travesty
Diagram- and graph-generating library for Akka Streams
Stars: ✭ 83 (-12.63%)
Mutual labels:  utility-library
Entity embeddings categorical
Discover relevant information about categorical data with entity embeddings using Neural Networks (powered by Keras)
Stars: ✭ 67 (-29.47%)
Mutual labels:  utility-library
Strtotime For Java
strtotime in Java
Stars: ✭ 8 (-91.58%)
Mutual labels:  utility-library

exotic

A bestiary of classes implementing exotic semantics in Java

In Java, a static final field is considered as a constant by the virtual machine, but a final field of an object which is a constant is not itself considered as a constant. Exotic allows to see a constant's field as a constant, a result of a calculation as a constant, to change at runtime the value of a constant, etc.

This library run on Java 8+ and is fully compatible with Java 9 modules.

This library needs Java 11+ to be built.

MostlyConstant - javadoc

A constant for the VM that can be changed by de-optimizing all the codes that contain the previous value of the constant.

private static final MostlyConstant<Integer> FOO = new MostlyConstant<>(42, int.class);
private static final IntSupplier FOO_GETTER = FOO.intGetter();

public static int getFoo() {
  return FOO_GETTER.getAsInt();
}
public static void setFoo(int value) {
   FOO.setAndDeoptimize(value);
}

StableField - javadoc

A field that becomes a constant if the object itsef is constant and the field is initialized

enum Option {
  a, b;
    
  private static final Function<Option, String> UPPERCASE =
      StableField.getter(lookup(), Option.class, "uppercase", String.class);
    
  private String uppercase;  // stable

  public String upperCase() {
    String uppercase = UPPERCASE.apply(this);
    if (uppercase != null) {
      return uppercase;
    }
    return this.uppercase = name().toUpperCase();
  }
}
...
Option.a.upperCase()  // constant "A"

ConstantMemoizer - javadoc

A function that returns a constant value if its parameter is a constant.

private static final ToIntFunction<Level> MEMOIZER =
    ConstantMemoizer.intMemoizer(Level::ordinal, Level.class);
...
MEMOIZER.applyAsInt("foo") // constant 3

ObjectSupport - javadoc

Provide a fast implementation for equals() and hashCode().

class Person {
  private static final ObjectSupport<Person> SUPPORT =
      ObjectSupport.of(lookup(), Person.class, p -> p.name);
    
  private String name;
  ...
  
  public boolean equals(Object other) {
    return SUPPORT.equals(this, other);
  }
    
  public int hashCode() {
    return SUPPORT.hashCode(this);
  }
}

StructuralCall - javadoc

A method call that can call different method implementations if they share the same name and same parameter types.

private static final StructuralCall IS_EMPTY =
    StructuralCall.create(lookup(), "isEmpty", methodType(boolean.class));

static boolean isEmpty(Object o) {  // can be called with a Map, a Collection or a String
  return IS_EMPTY.invoke(o);
}

Visitor - javadoc

An open visitor, a visitor that does allow new types and new operations, can be implemented using a Map that associates a class to a lambda, but this implementation loose inlining thus perform badly compared to the Gof Visitor. This class implements an open visitor that's used inlining caches.

private static final Visitor<Void, Integer> VISITOR =
    Visitor.create(Void.class, int.class, opt -> opt
      .register(Value.class, (v, value, __) -> value.value)
      .register(Add.class,   (v, add, __)   -> v.visit(add.left, null) + v.visit(add.right, null))
    );
...
Expr expr = new Add(new Add(new Value(7), new Value(10)), new Value(4));
int value = VISITOR.visit(expr, null);  // 21

TypeSwitch - javadoc

Express a switch on type as function from an object to an index + a classical switch on the possible indexes. The TypeSwitch should be more efficient than a cascade of if instanceof.

private static final TypeSwitch TYPE_SWITCH = TypeSwitch.create(true, Integer.class, String.class);
  
public static String asString(Object o) {
  switch(TYPE_SWITCH.typeSwitch(o)) {
  case TypeSwitch.NULL_MATCH:
    return "null";
  case 0:
    return "Integer";
  case 1:
    return "String";
  default: // TypeSwitch.NO_MATCH
    return "unknown";
  }
}

Build Tool Integration

Get latest binary distribution via JitPack

Maven

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependency>
    <groupId>com.github.forax</groupId>
    <artifactId>exotic</artifactId>
    <version>master-SNAPSHOT</version>
</dependency>

Gradle

repositories {
    ...
    maven { url 'https://jitpack.io' }
}
dependencies {
    compile 'com.github.forax:exotic:master-SNAPSHOT'
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].