我在GitHub上的私有存储库中有一个Java应用程序,我想与没有帐户的人共享它.我没有在网站上找到任何选项.
有没有办法做到这一点?协作者只能是GitHub用户.
我Customer从我读过的文件中生成一个列表.我将这些客户存储HashMap在密钥是唯一ID的位置:
Map<String, Customer> customers = readCustomers();
//For each object created
customers.put(c.getCustomerId(), c);
从第二个文件中我获取了用于更新对象的数据HashMap.我使用密钥来查找要更新的对象:
//get the details informations
customers.get(customerId).setDetails(details);
在java 8中我可以使用:
class Customer{
...
public static Customer find(List<Customer> customers, int id) {
return customers.stream().filter(c -> c.customerId == id).findAny().get();
}
}
//usage
List<Customer> customers = readCustomers();
...
Customer.find(customers, 21).setDetails(details);
Run Code Online (Sandbox Code Playgroud)
使用Java 8方法会有性能提升吗?这些方法之间的最佳实践是什么?