Skip to content

Instantly share code, notes, and snippets.

View johnmcclean's full-sized avatar

John McClean johnmcclean

  • Oath
  • Dublin
View GitHub Profile
public class MutableArrayList<E> {
private int size;
private E[] elementData;
public E set(int index, E e) {
E oldValue = elementData[index];
elementData[index] = e;
return oldValue;
public class Processor {
private final AuthorizationService3 authService;
private final Executor exec = Executors.newCachedThreadPool();
public Either<Error,Vector<String>> processUsersFiles(User user, NonEmptyList<DataFileMetadata> files){
return authService.isAuthorized(user, files)
.flatMap(this::loadContents);
@AllArgsConstructor
public class Processor {
public static enum Error {
NO_PERMISSIONS
}
private final AuthorizationService authService;
private final Executor exec = Executors.newCachedThreadPool();
public Either<Error,Vector<String>> processUsersFiles(User user, NonEmptyList<DataFileMetadata> files){
@AllArgsConstructor
@Getter
public abstract class DataFileMetadata {
public LazyEither<IOException,String> loadAsync(Executor ex){
}
}
public class Processor {
public static enum Error {
NO_PERMISSIONS
}
private final AuthorizationService authService;
public Either<Error,Vector<String>> processUsersFiles(User user, NonEmptyList<DataFileMetadata> files){
return authService.isAuthorized(user, files)
.map(this::loadContents);
@AllArgsConstructor
public class Processor {
private final AuthorizationService authService;
public Vector<String> processUsersFiles(User user, NonEmptyList<DataFileMetadata> files){
if(authService.isAuthorized(user)){
return files.map(DataFileMetadata::getContents)
.vector();
public class NonLocking {
Executor ex = Executors.newCachedThreadPool();
public ReactiveSeq<Result> processData(Map<Long,List<Data>> data) {
return new LazyReact(ex).fromIterable(data.entrySet())
.flatMap(e -> this.process(e.getKey(), e.getValue()));
package com.nullex.nolocks.immutable;
import com.nullex.Data;
import cyclops.control.Future;
import cyclops.futurestream.FutureStream;
import cyclops.futurestream.LazyReact;
import cyclops.reactive.FluxReactiveSeq;
import cyclops.reactive.ReactiveSeq;
import cyclops.reactive.Spouts;
import lombok.Getter;
@AllArgsConstructor
@Getter
public abstract class DataFileMetadata {
private final long customerId;
private final String type;
private final Either<IOException,String> contents = LazyEither.lazy(this::loadContents);
protected abstract Either<IOException,String> loadContents();
@AllArgsConstructor
@Getter
public abstract class DataFileMetadata {
private final long customerId;
private final String type;
private final Option<String> contents = Maybe.fromEval(Eval.later(this::loadContents))
.concatMap(Function.identity());
protected abstract Option<String> loadContents();