org.dromara.hutool.extra.management.JavaSpecInfo Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2023 looly([email protected])
* Hutool is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
package org.dromara.hutool.extra.management;
import org.dromara.hutool.core.util.SystemUtil;
import java.io.Serializable;
/**
* 代表Java Specification的信息。
*/
public class JavaSpecInfo implements Serializable{
private static final long serialVersionUID = 1L;
private final String JAVA_SPECIFICATION_NAME = SystemUtil.get("java.specification.name", false);
private final String JAVA_SPECIFICATION_VERSION = SystemUtil.get("java.specification.version", false);
private final String JAVA_SPECIFICATION_VENDOR = SystemUtil.get("java.specification.vendor", false);
/**
* 取得当前Java Spec.的名称(取自系统属性:{@code java.specification.name})。
*
*
* 例如Sun JDK 1.4.2:{@code "Java Platform API Specification"}
*
*
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回{@code null}。
*
*/
public final String getName() {
return JAVA_SPECIFICATION_NAME;
}
/**
* 取得当前Java Spec.的版本(取自系统属性:{@code java.specification.version})。
*
*
* 例如Sun JDK 1.4.2:{@code "1.4"}
*
*
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回{@code null}。
*
* @since Java 1.3
*/
public final String getVersion() {
return JAVA_SPECIFICATION_VERSION;
}
/**
* 取得当前Java Spec.的厂商(取自系统属性:{@code java.specification.vendor})。
*
*
* 例如Sun JDK 1.4.2:{@code "Sun Microsystems Inc."}
*
*
* @return 属性值,如果不能取得(因为Java安全限制)或值不存在,则返回{@code null}。
*
*/
public final String getVendor() {
return JAVA_SPECIFICATION_VENDOR;
}
/**
* 将Java Specification的信息转换成字符串。
*
* @return JVM spec.的字符串表示
*/
@Override
public final String toString() {
final StringBuilder builder = new StringBuilder();
ManagementUtil.append(builder, "Java Spec. Name: ", getName());
ManagementUtil.append(builder, "Java Spec. Version: ", getVersion());
ManagementUtil.append(builder, "Java Spec. Vendor: ", getVendor());
return builder.toString();
}
}