manifold.ext.rt manifold @Extension

在使用 manifold 的时候需要以下步骤:

If you simply want to experiment with Manifold, this project will help get you started.

  • git clone https://github.com/manifold-systems/manifold-sample-project.git
  • Open IntelliJ IDEA
  • Install the Manifold plugin from within IntelliJ: Settings | Plugins | Marketplace
  • Restart IntelliJ to use the plugin
  • Open the project you just cloned (open the root directory or the pom.xml file)
  • Add the Java 11 JDK: File | Project Structure | SDKs | + | path-to-your-Jdk11
  • Set the project JDK and language level: File | Project Structure | Project select 11 for both Project JDK and Project language level
  • Build the project
  • Examine the abc/RunMe.java file
1. map 扩展
package manifoldsampleproject.extensions.java.util.Map;


import manifold.ext.rt.api.Extension;
import manifold.ext.rt.api.This;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

@Extension
public class MyMapExtension {
  public static <K, V> boolean containsKeys(@This Map<K, V>  thiz, Collection<K> keys) {
    return thiz.keySet().containsAll(keys);
  }

  public static class Entry {
    public static <K, V> String hiFromEntry(@This Map.Entry<K, V> thiz) {
      return "hiFromEntry";
    }
  }

  /**
   * 我的put
   * @param thiz
   * @param k
   * @param v
   * @param <K>
   * @param <V>
   * @return
   */
  public static <K, V>  Map<K, V> myPut(@This Map<K,V> thiz,K k,V v){
    thiz.put(k,v);
    return  thiz;
  }
}
2. 字符串扩展
package manifoldsampleproject.extensions.java.lang.String;

import manifold.ext.rt.api.Extension;
import manifold.ext.rt.api.This;

import java.lang.String;

@Extension
public class MyStringExt {
  public static void echo( @This String thiz) {
    System.out.println(thiz);
  }

  public static void print( @This String thiz) {
    System.out.println(thiz+"qqq");
  }


}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值