com.zusmart.basic.scanner.support.AbstractScannerResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zusmart-basic Show documentation
Show all versions of zusmart-basic Show documentation
基础模块,提供配置,日志,SPI,图排序,路径匹配,资源扫描,包扫描,常用工具类
package com.zusmart.basic.scanner.support;
import java.net.URL;
import com.zusmart.basic.scanner.Scanner;
import com.zusmart.basic.scanner.ScannerResult;
import com.zusmart.basic.scanner.ScannerResultType;
import com.zusmart.basic.toolkit.StringUtils;
public abstract class AbstractScannerResult implements ScannerResult {
protected URL url;
protected String name;
protected AbstractScannerResult(URL url, String name) {
if (null == url) {
throw new IllegalArgumentException("url must not be null");
}
if (StringUtils.isBlank(name)) {
throw new IllegalArgumentException("name must not be empty");
}
this.url = url;
this.name = name;
}
@Override
public URL getTargetURL() {
return this.url;
}
@Override
public String getTargetName() {
return this.name;
}
@Override
public boolean isTargetClass() {
return this.getTargetType() == ScannerResultType.Class;
}
@Override
public boolean isTargetResource() {
return this.getTargetType() == ScannerResultType.Resource;
}
@Override
public int hashCode() {
return this.toString().hashCode();
}
@Override
public boolean equals(Object obj) {
if (null == obj) {
return false;
}
if (obj instanceof Scanner) {
return this.toString().equals(obj.toString());
}
return false;
}
@Override
public String toString() {
return String.format("[%s]%s#%s", this.getTargetType(), this.getTargetURL(), this.getTargetName());
}
}