我们说我有一些课
$img = $_POST['data'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$fileData = base64_decode($img);
//saving
$fileName = 'photo.png';
file_put_contents($fileName, $fileData);
我能以某种方式要求public class SomeClass<T> {
public SomeClass() {
//or throw exception here if T is not an interface but this is not preferred.
}
}
让T
和equals
覆盖hashCode
的实施吗?我能想到的一种方法是使用这样的东西:
Object
但我确实想使用抽象类方法,因为我不能使用任何扩展其他类的类(没有多重继承,并且使用包装器只会添加更多的样板)。
对于例外路线,我可以使用一些东西 How to check if a class has overridden equals and hashCode 和https://stackoverflow.com/a/13974262/5130921。