You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Eyso Zanstra (JIRA)" <ji...@apache.org> on 2018/06/19 12:53:00 UTC
[jira] [Closed] (NETBEANS-789) Omitting a generic type has a
cascading effect;
[ https://issues.apache.org/jira/browse/NETBEANS-789?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eyso Zanstra closed NETBEANS-789.
---------------------------------
Resolution: Information Provided
> Omitting a generic type has a cascading effect;
> ------------------------------------------------
>
> Key: NETBEANS-789
> URL: https://issues.apache.org/jira/browse/NETBEANS-789
> Project: NetBeans
> Issue Type: Bug
> Affects Versions: 8.2
> Environment: Windows 8.1 64 bit
> Processor Intel i7-4720HQ @2.60Ghz
> 16GB RAM
> Reporter: Eyso Zanstra
> Priority: Major
>
> Example code:
>
> {code:java}
> package util;
> import java.util.Collection;
> import java.util.HashSet;
> import java.util.Set;
> import java.util.Optional;
> /**
> *
> * @author eyso
> * @param <T> example generic
> */
> public class Foo<T> {
> private final T val;
> private Optional<Long> timestamp = Optional.<Long>empty();
> public Foo(T val) {
> this.val = val;
> timestamp = Optional.of(System.currentTimeMillis());
> }
> public Optional<Long> getTimestamp() {
> return timestamp;
> }
> public static Set<Long> getTimestamps(Collection<Foo> foos) {
> Set<Long> result = new HashSet<Long>();
> for (Foo foo : foos) {
> if (foo.getTimestamp().isPresent()) {
> result.add(foo.getTimestamp().get()); //Argument mismatch;
> }
> }
> return result;
> }
> }
> {code}
> This raises an error: Argument mismatch; Object cannot be converted to Long
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists