All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zusmart.basic.scanner.support.AbstractScannerResult Maven / Gradle / Ivy

Go to download

基础模块,提供配置,日志,SPI,图排序,路径匹配,资源扫描,包扫描,常用工具类

There is a newer version: 0.0.3
Show newest version
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());
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy