Skip to content

Instantly share code, notes, and snippets.

@aploskov
Created September 4, 2018 18:16
Show Gist options
  • Save aploskov/b4000e0e84349385a2ab55d8002512c5 to your computer and use it in GitHub Desktop.
Save aploskov/b4000e0e84349385a2ab55d8002512c5 to your computer and use it in GitHub Desktop.
Блядская проблема для проверки блядского отношения типа id к сущности, которую я пока что не решил.
package com.example;
import java.io.Serializable;
import java.util.List;
interface HasId<Id extends Serializable, Entity extends HasId<Id, Entity>> {
Id getId();
Entity setId(final Id id);
}
interface Service<Id extends Serializable, C extends HasId<Id, C>> {
C getById(final Id id);
}
interface ConcreteService extends Service<Integer, Entity> {
/**
* @param id проблема тут, мне нужно убедиться, что id - это {@link Entity#id}, а не id другой сущности.
* @param <T> другая сущность, получаемая по {@link Entity#id}.
* @return список этих блядских сущностей.
*/
<T> List<T> getTList(final Integer id);
}
final class Entity implements HasId<Integer, Entity> {
private Integer id;
@Override
public Integer getId() {
return id;
}
@Override
public Entity setId(final Integer id) {
this.id = id;
return this;
}
}
final class ConcreteServiceImpl implements ConcreteService {
@Override
public Entity getById(Integer integer) {
return null;
}
@Override
public <T> List<T> getTList(Integer id) {
return null;
}
}
public class Main {
public static void main(String[] args) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment