java.lang.Object.clone()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中java.lang.Object.clone()方法的一些代码示例,展示了Object.clone()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Object.clone()方法的具体详情如下:
包路径:java.lang.Object
类名称:Object
方法名:clone

Object.clone介绍

暂无

代码示例

代码示例来源:origin: log4j/log4j

/**
  * Create new instance.
  * @since 1.2.15
  * @param r String representation of throwable.
  */
public ThrowableInformation(final String[] r) {
  if (r != null) {
   rep = (String[]) r.clone();
  }
}

代码示例来源:origin: alibaba/canal

public LogPosition clone() {
  try {
    return (LogPosition) super.clone();
  } catch (CloneNotSupportedException e) {
    // Never happend
    return null;
  }
}

代码示例来源:origin: jenkinsci/jenkins

@Override
  protected CLICommand createClone() {
    try {
      return (CLICommand)clone();
    } catch (CloneNotSupportedException e) {
      throw new AssertionError(e);
    }
  }
}

代码示例来源:origin: prestodb/presto

/**
 * Clone this object.
 *
 * @return a clone of this object.
 */
public Object clone() {
  try {
    return super.clone();
  } catch (CloneNotSupportedException ex) {
    throw new InternalError("Clone error");
  }
}

代码示例来源:origin: prestodb/presto

/**
 * Clone this object.
 *
 * @return a clone of this object.
 */
public Object clone() {
  try {
    return super.clone();
  } catch (CloneNotSupportedException ex) {
    throw new InternalError("Clone error");
  }
}

代码示例来源:origin: prestodb/presto

/**
 * Clone this object.
 *
 * @return a clone of this object.
 */
public Object clone() {
  try {
    return super.clone();
  } catch (CloneNotSupportedException ex) {
    throw new InternalError("Clone error");
  }
}

代码示例来源:origin: redisson/redisson

/**
 * Creates and returns a copy of this object.
 * The constant pool object is shared between this object
 * and the cloned object.
 */
public Object clone() throws CloneNotSupportedException {
  ExceptionTable r = (ExceptionTable)super.clone();
  r.entries = new ArrayList(entries);
  return r;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * Constructor that creates a matcher from a character array.
 *
 * @param chars  the characters to match, must not be null
 */
CharSetMatcher(char chars[]) {
  super();
  this.chars = (char[]) chars.clone();
  Arrays.sort(this.chars);
}

代码示例来源:origin: apache/incubator-druid

@Override
 public WordIterator clone()
 {
  try {
   return (WordIterator) super.clone();
  }
  catch (CloneNotSupportedException e) {
   throw new RuntimeException(e);
  }
 }
}

代码示例来源:origin: apache/incubator-druid

@Override
 public Offset clone()
 {
  try {
   return (Offset) super.clone();
  }
  catch (CloneNotSupportedException e) {
   throw new RuntimeException(e);
  }
 }
}

代码示例来源:origin: apache/flink

public RequestedGlobalProperties clone() {
  try {
    return (RequestedGlobalProperties) super.clone();
  } catch (CloneNotSupportedException cnse) {
    // should never happen, but propagate just in case
    throw new RuntimeException(cnse);
  }
}

代码示例来源:origin: apache/flink

@Override
  public Costs clone() {
    try {
      return (Costs) super.clone();
    } catch (CloneNotSupportedException e) {
      throw new RuntimeException(e);	// should never happen
    }
  }
}

代码示例来源:origin: Tencent/tinker

/**
 * Returns a deep copy of this zip entry.
 */
@Override public Object clone() {
  try {
    TinkerZipEntry result = (TinkerZipEntry) super.clone();
    result.extra = extra != null ? extra.clone() : null;
    return result;
  } catch (CloneNotSupportedException e) {
    throw new AssertionError(e);
  }
}

代码示例来源:origin: square/okhttp

@Override public MockResponse clone() {
 try {
  MockResponse result = (MockResponse) super.clone();
  result.headers = headers.build().newBuilder();
  result.promises = new ArrayList<>(promises);
  return result;
 } catch (CloneNotSupportedException e) {
  throw new AssertionError();
 }
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Override
  public CloneableString clone() throws CloneNotSupportedException {
    return (CloneableString)super.clone();
  }
}

代码示例来源:origin: redisson/redisson

public Object clone() throws CloneNotSupportedException {
  ByteVector bv = (ByteVector)super.clone();
  bv.buffer = (byte[])buffer.clone();
  return bv;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * Gets a copy of the full token list as an independent modifiable array.
 *
 * @return the tokens as a String array
 */
public String[] getTokenArray() {
  checkTokenized();
  return (String[]) tokens.clone();
}

代码示例来源:origin: Tencent/tinker

@Override
public SparseIntArray clone() {
  SparseIntArray clone = null;
  try {
    clone = (SparseIntArray) super.clone();
    clone.mKeys = mKeys.clone();
    clone.mValues = mValues.clone();
  } catch (CloneNotSupportedException cnse) {
    /* ignore */
  }
  return clone;
}

代码示例来源:origin: Tencent/tinker

@Override
public SparseBoolArray clone() {
  SparseBoolArray clone = null;
  try {
    clone = (SparseBoolArray) super.clone();
    clone.mKeys = mKeys.clone();
    clone.mValues = mValues.clone();
  } catch (CloneNotSupportedException cnse) {
    /* ignore */
  }
  return clone;
}

代码示例来源:origin: google/guava

final void testAllDeclarations() throws Exception {
 checkState(method == null);
 Method[] methods = getClass().getMethods();
 Arrays.sort(
   methods,
   new Comparator<Method>() {
    @Override
    public int compare(Method a, Method b) {
     return a.getName().compareTo(b.getName());
    }
   });
 for (Method method : methods) {
  if (method.isAnnotationPresent(TestSubtype.class)) {
   method.setAccessible(true);
   SubtypeTester tester = (SubtypeTester) clone();
   tester.method = method;
   method.invoke(tester, new Object[] {null});
  }
 }
}

相关文章